ITeye博客

平时工作经常用到的标签

Michael.solofly · 2009-09-18 09:26 · 工作收集 · Markdown

包含页面

<jsp:include page="xx.jsp" flush="true"/> //动态包含页面

<% @include file="" %>//静态包含页面     

具体区别请用鼠标温柔的杵这里

<%@ page  isELIgnored="false"%>//EL表达式可用
${pageContext.request.contextPath} //项目路径,效果同<%=request.getContextPath()%>
${param.value} //URL上的某个值(value为值的名字)

logic标签

<%@ taglib uri"http://struts.apache.org/tags-logic" prefix="logic" %> 

//在作用域session中没有找到user对象,那么显示<span> 
<logic:empty name="user" scope="session"> 
      <span>高级搜索</span> 
</logic:empty> 

//在作用域session中找到了user对象,那么显示<span> 
<logic:notEmpty name="user" scope="session"> 
      <span>高级搜索</span> 
</logic:notEmpty> 

//fwxx Bean中的uid属性的值和value="${sessionScope.user.uid}">的值相等,那么执行<a> 
<logic:equal name="fwxx" property="uid" value="${sessionScope.user.uid}"> 
	[<a href="...">编辑</a>] [<a href="...">删除</a>] 
</logic:equal> 

//fwxx Bean中的uid属性的值和value="${sessionScope.user.uid}">的值不相等,那么执行<a> 
<logic:notEqual name="fwxx" property="uid" value="${sessionScope.user.uid}"> 
	[<a href="...">编辑</a>] [<a href="...">删除</a>] 
</logic:notEqual> 

//list中所有的值,fwxx是Bean实例化的对象   fwxx.zj是对象.方法的意思Length为最大迭代次数
<logic:iterate id="fwxx" name="list"  length="3"> 
${fwxx.zj}元 
</logic:iterate> 

bean标签


//使用 bean:write 格式化输出
<logic:iterate id="fwxx" name="list"> 
<bean:write name="fwxx" property="zj" format="#,###" />元 
<bean:write name="fwxx" property="date" format="yyyy年MM月dd日" /> 
</logic:iterate>

//使用 bean:define 定义页面变量 
<bean:define id="dataList" name="list" type="java.util.List" scope="request" /> 

//使用bean:size得到集合数据记录 
<bean:size id="count" name="list" /> 

JSTL中的C标签


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

//全局变量
<c:set var="ctype" value="${param.ctype}" />//var为使用名, value是值

//判断
<c:if test="${ value eq 0}">
   如果value=0则输出这一段话
</c:if>

//eq(等于) ne(不等于) lt(小于) gt(大于)

//循环, items为request里面取出的List  var为取值时用的名称 begin是开始的条数end为结束的条数
<c:forEach items="${detillist}" var="item" begin="5" end="5">
</c:forEach>


<c:choose>
  <c:when test="${student.deptno == 'd003'}">
       <font color="blue">
  </c:when>
  <c:when test="${student.deptno == 'd004'}">
       <font color="red">
  </c:when>
  <c:otherwise>
       <font color="green"> 
  </c:otherwise>       
</c:choose>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。