The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the asso

忘是亡心i 2022-05-30 04:18 245阅读 0赞

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. - [unknown location]

  1. web.xml如下:
  2. <filter>
  3. <filter-name>struts2</filter-name>
  4. <filter-class>
  5. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  6. </filter-class>
  7. </filter>
  8. <filter-mapping>
  9. <filter-name>struts2</filter-name>
  10. <url-pattern>*.action</url-pattern>
  11. </filter-mapping>
  12. 折腾了好久,原来是因为控制器只处理了。action的访问,需要把.jsp也交给控制器处理才能正确使用struts标签。解决方法就是在web.xml加入以下配置:
  13. <filter-mapping>
  14. <filter-name>struts2</filter-name>
  15. <url-pattern>*.jsp</url-pattern>
  16. </filter-mapping>

这样struts自带的验证就能正常显示了

20180305091756385

发表评论

表情:
评论列表 (有 0 条评论,245人围观)

还没有评论,来说两句吧...

相关阅读