请问struts中的forward问题!!!

dupontwh 2003-10-17 11:21:13
我在struts-config.xml中定义了<forward name="month_plan_all" path="./plan/plan_all.jsp" />,并在jbuilder中编写代码。
我有两个页面,一个是DefaultWebApp目录下的main.jsp,一个是DefaultWebApp/plan目录下的plan_all.jsp,
流程是从main.jsp进入action,再转入plan_all.jsp,同时jsp文件放在服务器的DefaultWebApp目录下,没有放在工程文件包的defaultroot下。
请问这种forward中的path设置对不对?
forward中的path是针对前一个进入action的jsp页面的目录而言的,还是针对根目录而言的?
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xcpxie011 2003-10-28
  • 打赏
  • 举报
回复
/plan/plan_all.jsp没错,我用过,你试试
hjgdgs 2003-10-18
  • 打赏
  • 举报
回复
见意你用绝对目录
gao277 2003-10-18
  • 打赏
  • 举报
回复
两者都可以,不信你用tomcat试验试验
煜知搬砖者 2003-10-17
  • 打赏
  • 举报
回复
<forward name="month_plan_all" path="./plan/plan_all.jsp" />

path后面的"."符号去掉,
dupontwh 2003-10-17
  • 打赏
  • 举报
回复
为什么我从action转入jsp时,jsp中显示如下信息:
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

dupontwh 2003-10-17
  • 打赏
  • 举报
回复
楼上各位好,我刚才试了,还是不行,我把详细情况再说一遍把:

我在weblogic的安装目录的DefaultWebApp目录下,有一个main.jsp文件,另外在DefaultWebApp/plan目录下有一个plan_all.jsp。
在jbuilder中,我把左边窗口的<Default Web App>目录下的Root directory的值设为weblogic的安装目录的DefaultWebApp目录,
然后,我想
(1)从main.jsp进入action,再转入plan_all.jsp,
在action中我用了return actionMapping.findForward("month_plan_all");
在struts-config.xml中我定义了<forward name="month_plan_all" path="/plan/plan_all.jsp" />,
但是,转入plan_all.jsp的结果却是
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

或者是Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.


(2)从main.jsp直接转入plan_all.jsp,
如在main.jsp中是用<a href ="/plan/plan_all.jsp">正确呢?(即映射到weblogic的安装目录的DefaultWebApp目录)
还是用<a href ="./plan/plan_all.jsp">正确呢?(即用相对目录)
dupontwh 2003-10-17
  • 打赏
  • 举报
回复
那个别的,例如我有两个页面,一个是DefaultWebApp目录下的mainxxx.jsp,一个是DefaultWebApp/plan目录下的plan_allxxx.jsp,
流程是从mainxxx.jsp不经过action,直接转入plan_allxxx.jsp,同时jsp文件放在服务器的DefaultWebApp目录下,没有放在工程文件包的defaultroot下。
那此时是用"./plan/plan_all.jsp" 还是用"/plan/plan_all.jsp" ???还是都可以???
chinaraul 2003-10-17
  • 打赏
  • 举报
回复
在action中最后的返回return:return actionMapping.getInputForward();中肯定有问题,你去看一下。
gao277 2003-10-17
  • 打赏
  • 举报
回复
"/plan/plan_all.jsp"就行了

forward中的path是针对前一个进入action的jsp页面的目录而言的是针对根目录而言的
show90 2003-10-17
  • 打赏
  • 举报
回复
path后面的"."符号去掉,

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧