ITeye博客

struts2标签应用 需在web.xml中 配置

mywebcode · 2013-11-04 17:03 · Markdown

1.在jsp页面上直接使用struts2的s标签,要求必须经过FileterDispatcher过滤,否则总会报错
org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter.Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.

解决办法:

Xml代码收藏代码

  1. <filter>
  2. <filter-name>struts2</filter-name>
  3. <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  4. </filter>
  5. <filter-mapping>
  6. <filter-name>struts2</filter-name>
  7. <url-pattern>*.action</url-pattern><!--过滤主要操作--> //action中用到
  8. </filter-mapping>
  9. <filter-mapping>
  10. <filter-name>struts2</filter-name> //jsp页面中,struts2标签需要用到
  11. <url-pattern>*.jsp</url-pattern>
  12. <!--因为若在jsp页面使用struts标签,就必须经过FilterDispacher的过滤,这样配置便可保证所有的jsp都经过FilterDispatcher了,否则要为每一个jsp写配置一个action地址转入-->
  13. </filter-mapping>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。