struts2的s:param标签主要有两个属性name与value, 若想在value属性中输入直接量,则可以这样写:<s:param name="some" value="%{'user'}"/>, 也可以这样写:<s:paramname="some">user</s:param>。但如果直接赋值,这个值不是由Action动态生成的,而是自己指定的一个字符串,则只能用后者。例:
一个分页程序中的jsp片段:
请注意其中的参数传递,分别用了前面介绍的俩种方式:<s:param name="currentPage" value="currentPage" /> 和 <s:param name="pagerMethod">last</s:param>。其中第一种方式中的currentPage是由Action动态生成的。而第二种方式中的last字符串是我自己页面指定的,如果这里也采用第一种方式的话,就不能传进这个参数。
注:action中应该有name为hot的对应的getter和setter方法
一个分页程序中的jsp片段:
<a href="<s:url action="showAllGoods.action">
<s:param name="currentPage" value="currentPage" />
<s:param name="pagerMethod">first</s:param>
</s:url>">首页</a>
<a href="<s:url action="showAllGoods.action">
<s:param name="currentPage" value="currentPage" />
<s:param name="pagerMethod">previous</s:param>
</s:url>">上一页</a>
<a href="<s:url action="showAllGoods.action">
<s:param name="currentPage" value="currentPage" />
<s:param name="pagerMethod" >next</s:param>
</s:url>">下一页</a>
<a href="<s:url action="showAllGoods.action">
<s:param name="currentPage" value="currentPage" />
<s:param name="pagerMethod">last</s:param>
</s:url>">尾页</a>
请注意其中的参数传递,分别用了前面介绍的俩种方式:<s:param name="currentPage" value="currentPage" /> 和 <s:param name="pagerMethod">last</s:param>。其中第一种方式中的currentPage是由Action动态生成的。而第二种方式中的last字符串是我自己页面指定的,如果这里也采用第一种方式的话,就不能传进这个参数。
以上来自于http://blog.sina.com.cn/s/blog_59a5c56301009uq9.html
两种类型
1、传的值是hot这个字符串
<s:a action="getsublist" encode="false"><s:param name="hot">hot</s:param>test--HOT </s:a>
2、传的变量hot的值,这个hot在之前曾有过赋值。如从“List”中得到的。。
<s:a action="getsublist" encode="false"><s:param name="hot" value="hot"></s:param>test--HOT </s:a>
注:action中应该有name为hot的对应的getter和setter方法