引用:
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" profix="logic"%>
jsp应用:
<logic:equal> 判断变量是否等于
<span style="white-space:pre"> </span>body里面
<% request.setAttribute("age",20);%>
如果相等输出age=20,否则不输出
<logic:equal name="age">
age=20
</logic:equal>
<logic:greaterEqual>判断变量是否大于等于
<logic:greaterThan>判断变量是否大于
<logic:lessEqual>判断变量是否小于等于
<logic:lessThan>判断变量是否小于
<logic:notEqual>判断变量是否不等于
<logic:empty>判断变量是否为空
<logic:match>判断变量是否包含指定的字符串
body里面
<% request.setAttribute("greeting","hello.amaker");%>
如果匹配输出,否则不输出
<logic:match name="greeting" value="hello">
match
</logic:20>
<logic:notMatch>
<logic:iterate>迭代
1 项目添加-MyEclipase-Add JSTL Libreries...
2 c.tld里面的uri: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" profix="c"%>
3 定义一个request.setAttribute("PersonList",list)
4 遍历
forEach可以不加JSTL
<c:forEach items="${PersonList}" var="per">
${per.id}
${per.name}
${per.age}
</c:forEach>
<logic:iterate id="p" name="PersonList">
${p.id}
${p.name}
${p.age}
</logic:iterate>
<logic:iterate id="p" name="PersonList">
<bean:write name="p" property="id"/>
<bean:write name="p" property="name"/>
<bean:write name="p" property="age"/>
</logic:iterate>