本文摘自互联网
原文发表地址:http://www.javah.net/Struts/20070505/740.html
<wbr>
1. <wbr> logic:empty
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>该标签是用来判断是否为空的。如果为空,该标签体中嵌入的内容就会被处理。该标签用于以下情况:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>1)当Java对象为null时;
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>2)当String对象为""时;
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>3)当java.util.Collection对象中的isEmpty()返回true时;
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>4)当java.util.Map对象中的isEmpty()返回true时。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>eg. <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:empty <wbr> name="userList"> <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>... <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> </logic:empty> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>该句等同于:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> if <wbr> (userList.isEmpty()) <wbr> { <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>... <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>} <wbr> <wbr> <wbr>
<wbr> <wbr> 2. <wbr> logic:notEmpty
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签的应用正好和logic:empty标签相反,略。
<wbr> <wbr> 3. logic:equal
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签为等于比较符。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg1. <wbr>比较用户的状态属性是否1,若为1,输出"启用";
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:equal <wbr> name="user" <wbr> property="state" <wbr> value="1">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 启用
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> </logic:equal>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg2. <wbr>如果上例中的value值是动态获得的,例如需要通过bean:write输出,因struts不支持标签嵌套,可采用EL来解决该问题。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:equal <wbr> name="charge" <wbr> property="num" <wbr> value="${business.num}"> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> ......
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> </logic:equal>
<wbr> <wbr> <wbr> <wbr>4. logic:notEqual
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>该标签意义与logic:equal相反,使用方法类似,略。
<wbr> <wbr> <wbr> <wbr>5. logic:forward
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签用于实现页面导向,查找配置文件的全局forward。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg. <logic:forward name="index"/>
<wbr> <wbr> <wbr> 6. logic:greaterEqual
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 为大于等于比较符。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg. <wbr>当某学生的成绩大于等于90时,输出“优秀”:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:greaterEqual name="student" property="score" value="90">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>优秀
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:greaterEqual>
<wbr> <wbr> <wbr> 7. logic:greaterThan
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此为大于比较符,使用方法同logic:greaterEqual,略;
<wbr> <wbr> <wbr> 8. logic:lessEqual
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此为小于等于比较符,使用方法同logic:greaterEqual,略;
<wbr> <wbr> <wbr> 9. logic:lessThan
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此为小于比较符,使用方法同logic:greaterEqual,略;
<wbr> <wbr> <wbr> 10. logic:match
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此标签比较对象是否相等;
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg1. 检查在request范围内的name属性是否包含"amigo"串: <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:match name="name" scope="request" value="amigo">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="name"/>中有一个“amigo”串。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:match>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg2. 检查在request范围内的name属性是否已“amigo”作为起始字符串:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:match name="name" scope="request" value="amigo" location="start">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="name"/>以“amigo”作为起始字符串。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:match>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg3. <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:match header="user-agent" value="Windows">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>你运行的是Windows系统
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:match>
<wbr> <wbr> <wbr> 11. <wbr>logic:notMatch
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此标签用于比较对象是否不相同,与logic:match意义相反,使用方法类似,略。
<wbr> <wbr> <wbr> <wbr> 12. logic:messagePresent
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签用于判断ActionMessages/ActionErrors对象是否存在;
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg. <wbr>如果存在error信息,将其全部输出:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:messagePresent property="error"> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><html:messages property="error" id="errMsg" > <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="errMsg"/> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></html:messages> <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:messagePresent >
<wbr> <wbr> <wbr> <wbr> <wbr>13. logic:messagesNotPresent
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签用于判断ActionMessages/ActionErrors对象是否不存在,使用方法与logic:messagePresent类似,略
<wbr> <wbr> <wbr> <wbr> <wbr> 14. logic:present
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此标签用于判断request对象传递参数是否存在。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>eg1. user对象和它的name属性在request中都存在时,输出相应字符串:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:present name="user" property="name">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>user对象和该对象的name属性都存在
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:present>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg2. 若有一个名字为“user”的JavaBean,输出对应字符串:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:present name="user" >
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>有一个名字为“user”的JavaBean。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:present>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>eg3. <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:present header="user-agent">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>we got a user-agent header.
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:present>
<wbr> <wbr> <wbr> <wbr> <wbr> 15. logic:notPresent
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 此标签用于判断request对象传递参数是否不存在,意义与了logic:present相反,使用方法类似,略。
<wbr> <wbr> <wbr> <wbr> <wbr> 16. logic:redirect
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 该标签用于实现页面转向,可传递参数。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg1. <logic:redirect href="http://www.chinaitlab.com"/>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr>17. logic:iterator
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> 用于显示列表为collection的值(List ,ArrayList,HashMap等)。
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg1. <wbr>逐一输出用户列表(userlList)中用户的姓名:
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:iterate <wbr> id="user" name="userList">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="user" property="name"/><br>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> </logic:iterate>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg2. <wbr>从用户列表中输出从1开始的两个用户的姓名
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:iterate <wbr> id="user" name="userList" indexId="index" <wbr> offset="1" length="2">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="index"/>.<bean:write name="user" property="name"/><br>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:iterate>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> eg3. logic:iterator标签的嵌套举例
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <logic:iterate id="user" indexId="index" name="userList">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="index"/>. <bean:write name="user" property="name"/><br>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><logic:iterate id="address" name="user" property="addressList" length="3" offset="1">
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr><bean:write name="address"/><br>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:iterate>
<wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr> <wbr></logic:iterate>
分享到:
相关推荐
标签:apache、struts2、plugin、struts、json、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,...
struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jarstruts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar
struts2-core-2.0.1.jar, struts2-core-2.0.11.1.jar, struts2-core-2.0.11.2.jar, struts2-core-2.0.11.jar, struts2-core-2.0.12.jar, struts2-core-2.0.14.jar, struts2-core-2.0.5.jar, struts2-core-2.0.6.jar,...
struts2-ssl-plugin-1.2.1.jar
struts2-json-plugin,Struts JSON插件
这个插件允许开发者在Struts 2中轻松地创建能够返回JSON的Action,使得前端(通常使用JavaScript库如jQuery)可以获取到JSON数据并进行进一步处理。 现在我们来详细讨论这两个库在实际应用中的作用: 1. **json-...
一旦配置完成,你就可以在JSP页面上直接使用Dojo的标签库,例如`<s:dojo>`和`<s:dojotheme>`,来创建和管理Dojo元素。 在实际开发中,你可能需要学习和理解以下几点: 1. Dojo的模块化系统(AMD,Asynchronous ...
struts2-struts1-plugin-2.1.6.jar
struts2-dojo-plugin-2.3.4 jar 日期控件的jar包 需要的自行下载
struts2-convention-plugin-2.3.15.1.jar
struts2-convention-plugin-2.3.24.1
在没有Struts2-Spring-Plugin的情况下,要在Struts2应用中使用Spring,需要手动配置Action类与Spring Bean之间的关联。而有了这个插件,配置过程变得更加简单。以下是Struts2-Spring-Plugin-2.2.1.jar提供的主要功能...
在Java Web开发中,这两个框架经常一起使用,Spring 提供了依赖注入(DI)和面向切面编程(AOP)等功能,而 Struts 2 则是一个强大的MVC(Model-View-Controller)框架,负责处理用户请求和业务逻辑。 Struts 2 和 ...
`struts2-tags-API`就是这样一个资源,它包含了Struts2标签API的详细文档,帮助开发者理解和使用这些标签。 一、Struts2标签概述 Struts2标签库是基于JSP标准标签库(JSTL)的扩展,它提供了一系列预定义的标签,...
默认的struts2-config-browser-plugin包中的ftl文件include标签路径用的相对路径,会找到包内的include文件,将包内ftl里include的路径改成的/开头的全路径。
在实际开发中,为了使用这个插件,你需要将`struts2-json-plugin-2.3.8.jar`文件放入项目的类路径(classpath)下,然后在Struts2的配置文件(通常为struts.xml)中启用JSON插件。在Action类中,定义返回JSON数据的...
struts2-jquery-plugin-3.1.0.jar
struts2-jfreechart-plugin-2.1.8.1.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.5.18.jar包下载,支持struts2的类库下载