访问Struts2的Action路径问题

访问Struts2的Action路径问题,第1张

一般来说,只要webxml中配置正确的映射路径,strutsxml能够实例化action就不会出现404错误,可能是webxml中的filter-mapping出现问题
<filter>
<filter-name>action</filter-name>
<filter- class>orgapachestruts2dispatcherFilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>action</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
你把<url-pattern>/</url-pattern>的内容改动后调试看看,good luck!
----------------------------
Struts2的路径和struts1的一致,/ 表示web应用更目录(就是GraPro目录),在struts2中FilterDispatcher就是根据你在webxml filter-mapping中配置的路径去映射你的请求路径(/newsaction),
如果匹配,就加载strutsxml中定义的actionMapping,然后转交action处理请求
你可以参考:http://wwwblogjavanet/max/archive/2006/10/10/74353html的说明吧
---------------------
因为responsesendRedirct("newsaction")是采用浏览器重新定位的方法去请求的,相当于你在地址栏直接输http://localhost:8080/GraPro/newsaction
而jsp:forward 是将request和response作为参数传递请求,它会读取web根目录+action path 作为请求URL

以上就是关于访问Struts2的Action路径问题全部的内容,包括:访问Struts2的Action路径问题、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9423848.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存