日期:2014-05-19  浏览次数:20864 次

使用struts2标签的问题
操作:struts2中直接访问jsp (此jsp页面含有struts2标签)
会报异常: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. 
环境:struts2
原因:如果想要在jsp文件中,采用 struts的tag,那么jsp必须是通过action跳转得到,也就是必须通过web.xml所配置的过滤器访问文件,否则会有异常。


解决方案:

方案一:

采用 http://ip:port/SayHello.action 访问

方案二:

将web.xml 的过滤器,从 *.action 修改为: /*

方案三:

修改SayHello.jsp 文件,不使用 struts 的标签。

除了以上方案,还有什么更好的方案??????????????

------解决方案--------------------
却是用JSTL+EL,相对来说要好一些!
------解决方案--------------------
而且我们的项目用的就是不能直接走jsp
必须action跳、

硬性规定了、
要么引用静态html
要么动态的就必须跳action