简体   繁体   English

从servlet转发到JSP导致HTTP 404

[英]Forwarding from servlet to JSP cause HTTP 404

I have seem some question similar like mine(like this one ), but none of them solved my question. 我似乎有一些类似我的问题(像这个问题 ),但是没有一个人解决了我的问题。 So I'll post one. 因此,我将发布一个。

My JSP website structure is like this: 我的JSP网站结构是这样的:

/subpage/funcA.jsp /main.jsp /subpage/funcA.jsp /main.jsp

My main page contains all necessary js and css definitions, subpages don't have those defines. 我的主页包含所有必要的js和css定义,子页面没有这些定义。 So If I'm going to display my funcA page properly, its URL will need to be written like this 因此,如果我要正确显示funcA页面,则需要这样写它的URL

Here's the problem: I'm trying to use forward() to send some attributes to funcA.jsp , so I can pre-fill those attributes into form texts in funcA.jsp. 这是问题所在:我正在尝试使用forward()将一些属性发送到funcA.jsp ,因此我可以将这些属性预先填充到funcA.jsp中的表单文本中。 But I can't get it working! 但是我无法正常工作! All I got is 404s. 我只有404个。

Here's my forward code: 这是我的转发代码:

RequestDispatcher dispatcher = getServletContext()
                        .getRequestDispatcher("/main.jsp#subpage/funcA.jsp");
dispatcher.forward(req, res);

Can anyone tell me what did I miss? 谁能告诉我我想念什么? thanks. 谢谢。

Since I got no way to find out "How" so far, and the deadline is near. 由于到目前为止我还没有办法了解“如何”,所以截止日期临近。 So I dodged this problem by storing data into session and response redirect method. 所以我通过将数据存储到会话和响应重定向方法中来回避了这个问题。 Move on to next problem. 继续下一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM