概述
一、概述
1.JSP文件中添加代码: <%@ taglib prefix="s" uri="/struts-tags" %>
2.OGNL
必须在struts中使用。
List集合 :{s1,s2,s3,...}
Map集合 :#{key1:value1,key2:value2,...}
二、控制标签
1.
<s:if test=" 表达式">
标签体
</s:if>
<s:elseif test="表达式">
标签体
</s:elseif>
<s:else test="表达式">
标签体
</s:else>
2.
<s:append var="newlist">
<s:param value=""/>
<s:param value=""/>
</s:append>
<s:iterator value="%{#newlist}" id="lst">
<s:property value="lst"/>
</s:iterator>
3.
<s:generator var=" " val=" " count=" " converter=" " separator=" "> <pre name="code" class="java"> <s:iterator>
<s:property />
</s:iterator>
</s:generator>
4.
<s:iterator var=" " value=" " begin=" " step=" " end=" " status=" " />
5.
<s:merge var="newlist">
<s:param value=""/>
<s:param value=""/>
</s:merge>
<s:iterator value="%{#newlist}" id="lst">
<s:property value="lst"/>
</s:iterator>
6.
必须自定义实现了java.util.Comparator接口的类
<s:sort var=" " source=" " Comparator=" " />
7.
自定义的截取类实现的接口: org.apache.struts2.util.SubsetIteratorFilter.Decider
<s:subset var=" " source=" " start=" " count=" " decider=" " />
8.
三、数据标签
1.
<s:a id=" " href=" " action=" " method=" " namespace=" " />
2.
<s:action var=" " name=" " executeResult=" " flush=" " ignoreContextParams=" " namespace=" " />
3.
<s:bean var=" " name=" " />
4.
<s:date var=" " name=" " nice=" " format=" " />
5.
<s:debug />
6.
<s:i18n name=" " /> !!资源绑定
7.
<s:include id=" " value=" ">
<s:param name=" " value=" " />
</s:include>
8. <s:param>
9.
<s:property value=" " default=" " /> !!输出ValueStack中的值
10.
<s:push value=" " /> !!将一个值放到ValueStack栈顶
11.
<s:set var=" " value=" " scope=" " /> !!将某个值放入指定范围内
12.
<s:text var=" " name=" " searchValueStack=" " /> !!输出国际化资源文件信息
13.
<s:url var=" " action|value=" " method=" " namespace=" " /> !!映射地址
四、表单标签
1.
<s:form action=" " namespace=" " />
2.
<s:submit action=" " method=" " />
3.
<s:checkbox name=" " label=" " value="true/false" fieldValue=" " />
4.
<s:checkboxlist name=" " label=" " list=" " listKey=" " listValue=" " />
5.
<s:combobox name=" " label=" " list=" " headerKey=" " headerValue=" " emptyOption=" " value=" "/>
6.
<s:doubleselect name=" " list=" " listKey=" " listValue=" " label=" "
doubleName=" " doublelist=" " doubleListKey=" " doubleListValue=" " multiple=" " />
7.
<s:head />
8.
<s:file name=" " accept=" " />
9.
<s:hidden neme=" " value=" " /> !!主要用来需要提交表单传值时使用
10
<s:inputtransferselect name=" " label=" " list=" " listKey=" " listValue=" " multiple=" "
upLabel=" " downLabel=" " addLabel=" " removeLabel=" " removeAllLabel=" "
allowMoveUp=" " allowMoveDown=" " />
11.
<s:label name=" " value=" " />
12.
<s:optiontransferselect label=" " leftTitle=" " rightTitle=" " name=" "
list=" " listKey=" " listValue=" " headerKey=" " headerValue=" " mutiple=" " emptyOption=" "
doubleList=" " doubleListKey=" " doubleListValue=" " doubleHeaderKey=" " doubleHeaderValue=" " doubleMutiple=" "/>
13.
<s:select name=" " label=" " list=" " listKey=" " listValue=" " headerKey=" " headerValue=" " />
14.
<s:optgroup label=" " list=" " listKey=" " listValue=" " />
!!通常放在<s:select>标签中用于生成一个下拉列表框的选项组
15.
<s:password name=" " label=" " size=" " maxlength=" " />
16.
<s:radio name=" " label=" " list=" " listKey=" " listValue=" " />
17.
<s:reset name=" " value=" " />
18.
<s:textarea name=" " value=" " rows=" " cols=" " />
<s:textfield name=" " value=" " />
19.
<s:token /> !!生成HTML中含有一个隐藏域,value属性值提交后放入session中,
须在struts.xml中配置拦截器如下:
<action name=" " class=" ">
<!--配置拦截器-->
<interceptor-ref name="defaultStack" />
<interceptor-ref name="token" />
<!--返回结果-->
<result name="invalid.token">/error.jsp</result>
<result>/success.jsp</result>
</action>
20.
<s:updownselect name=" " list=" " listKey=" " listValue=" " headerKey=" " headerValue=" " emptyOption=" "
moveUpLabel=" " moveDownLabel=" " selectAllLabel=" " />
五、非表单标签
输出在Action中封装的信息
1.
<s:actionerror /> !!输出Action实例中getActionError()的返回值
2.
<s:actionmessager /> !!输出Action实例中getActionMessage()的返回值
3.
<s:component /> !!用来使用自定义标签、模板、主题等
4.
<s:div id=" " class=" " />
5.
<s:fielderror /> !!输出Action中的fieldErrors属性保存的字段错误。
最后
以上就是英俊哈密瓜为你收集整理的Struts标签库的全部内容,希望文章能够帮你解决Struts标签库所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复