Struts2+sitemesh 在decorators page 中获取参数值的3种方式

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:131291778; mso-list-type:hybrid; mso-list-template-ids:248551850 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} -->

Struts2+sitemesh  如何在decorators page 中获取参数值

关于如何在decorators page 中获取请求参数值的问题,大致有3个方法,

  1. SiteMesh document上提出的,使用<decorator:usePage id="p" /> 然后使用java脚本获取<%= p.getRequest().getParameter("parametername") %>,这种方式不是很好,若使用的地方比较多的话,会使得decorator page中充满了java 脚本。
  2. 使用jstl 直接获取,${param.parametername}
  3. 使用struts2 的标签<s:property value="#parameters.parametername" /> 但是这种方法必须在web.xml 中加入struts-cleanup servlet,且要注意顺序,如下:

      <!-- 排在第一位的过滤器是:ActionContextCleanUp过滤器。 --><!--

      <filter-mapping>

            <filter-name>struts-cleanup</filter-name>

            <url-pattern>/*</url-pattern>

      </filter-mapping>

       --><!-- 排在第二位的过滤器是:SiteMesh核心过滤器。 -->

      <filter-mapping>

            <filter-name>sitemesh</filter-name>

            <url-pattern>/*</url-pattern>

            <dispatcher>FORWARD</dispatcher>

            <dispatcher>REQUEST</dispatcher>

      </filter-mapping>

      <!-- 排在第三位的过滤器是:FilterDispatcher过滤器。 -->

      <filter-mapping>

            <filter-name>struts2</filter-name>

            <url-pattern>/*</url-pattern>

   </filter-mapping>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值