使用 Struts2 的 RequestDispatcher
目前,我无法从 Struts2 获取请求调度程序,如下所示:
RequestDispatcher rd = httpReq.getRequestDispatcher("/category.htm");
错误如下所示:
The requested resource (/xxxx/category.htm) is not available.
但在执行 http:/xxxx/yyyy/category.htm?id=21
时运行良好 有人知道吗?
Currently I fail to getRequestDispatcher
from Struts2 as below:
RequestDispatcher rd = httpReq.getRequestDispatcher("/category.htm");
Error was show as below:
The requested resource (/xxxx/category.htm) is not available.
but it working well when http:/xxxx/yyyy/category.htm?id=21
execute
does anyone have idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它适用于
/category.htm
URL,点击?id=21
,但会转到/xxx/yyy/category.htm
,那么您就不会发出与getRequestDispatcher()
调用中的最终 URL 相同的请求。试试这个:If it works with the
/category.htm
URL hitting?id=21
, but that goes to/xxx/yyy/category.htm
, then you're not making the same request as the final URL in yourgetRequestDispatcher()
invocation. Try this instead:无论如何,问题可以通过下面的帖子解决,感谢约翰的回复:)
http://old.nabble.com/Block-accessing-in-some-path-with-filter.-td23631279.html
我所做的只是将这些添加到过滤器映射元素中对于 web.xml 中的 struts 过滤器:
Problem resolve with post below, anyway, thanks John for your reply :)
http://old.nabble.com/Block-accessing-in-some-path-with-filter.-td23631279.html
What I did is just added these into filter-mapping element for struts filter in web.xml: