请教:我的这个structs 应用系统中,有错误:Invalid path /testOracle was requested

cwbnig 2004-09-10 10:29:40
===================================================================
地址栏输入
http://localhost:4040/testOracle.jsp

打开该页面中的一超连接:
http://localhost:4040/testOracle.do?forward=bdgk

出现下面的错误:

type Status report

message Invalid path /testOracle was requested

description The request sent by the client was syntactically incorrect (Invalid path /testOracle was requested).
===================================================================



===================================================================
平台:windows 2000 pro + Apache Tomcat/5.0.12
===================================================================



===================================================================
testOracle.jsp 部分代码:

<a href="testOracle.do?forward=bdgk">testOracle.do?forward=bdgk</a>
===================================================================



===================================================================
struts-config.xml 部分代码:

<struts-config>
<form-beans/>
<global-forwards/>
<action-mappings>
<action path="/testOracle" type="com.cwbnig.TestOracle" parameter="forward"/>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
</struts-config>
===================================================================



===================================================================
TestOracle.java代码:

package com.cwbnig;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.DispatchAction;
public class TestOracle extends DispatchAction
{
public TestOracle()
{
super();
}

public ActionForward bdgk(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
{
System.out.println("============================");
return new ActionForward("createUser.jsp");
}
}
===================================================================



===================================================================
我认为的错误:尚不清楚。给出的提示,似乎是说找不到该页面,因为又是400错误。
请各位朋友赐教,谢谢。
===================================================================
...全文
147 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hfniit 2004-09-10
  • 打赏
  • 举报
回复
你的JSP和STRUTS-CONFIG.XML代码有错误.
testOracle.jsp 部分代码:
<a href="testOracle.do?forward=bdgk">testOracle.do?forward=bdgk</a>


应该写成
testOracle.jsp 部分代码:

<a href="<%= request.getContextPath() %>/testOracle.do">
testOracle.do?forward=bdgk
</a>

<-------struts-config.xml----->>
<action-mappings>
<action path="/testOracle"
type="com.cwbnig.TestOracle" --->执行的JAVA类.
parameter="forward"> -->这个是XML传给TestOracle类的一个参数.
<forward name="这里是类的返回值" path="这里是你所需要指向的下一个'.do',或者是某个'.jsp'" />
</action>
</action-mappings>

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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