求教,求教:程序走不到Action

coolsboy
03-04-14 4 199

web/WEB-INF/struts-config.xml :
<form-bean name="loginForm" type="com.hitachijoho.keiri.kaikei.web.struts.forms.LoginForm"/>
<!-- ========== Global Forward Definitions ============================== -->
<global-forwards>
<forward name="logoff" path="/logoff.do"/>
<forward name="logon" path="/logon.jsp"/>
<forward name="index" path="/smenu.jsp"/>
<forward name="denpyoMenu" path="/denpyoMenu.do"/>
<forward name="success" path="/index.jsp"/>
<forward name="failure" path="/errorpage.jsp"/>
</global-forwards>

<!-- ========== Action Mapping Definitions ============================== -->

<action path="/login"
type="com.hitachijoho.keiri.kaikei.web.struts.actions.LoginAction"
name="loginForm"
scope="session"
validate="false"
input="/login.jsp">
<forward name="success" path="/smenu.jsp"/>
</action>

当页面提交的后出现error:

Apache Tomcat/4.0.6 - HTTP Status 400 - Invalid path /index was requested

--------------------------------------------------------------------------------

type Status report

message Invalid path /index was requested

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

这是什么原因哪?
谢谢了

jxb8901
2003-04-15 14:40

客户端请不仅是没有到action, 而且根本没有到达struts, 你应该看一下登录页面中form的action有没有设置正确. 要注意action="/login"和action="login"的区别.

coolsboy
2003-04-16 15:44

login.JSP里是这么写的:
<html:form action="/login.do" styleId="formMain" method="post">

生成HTML后:
<form name="loginForm" method="post" action="/kaikei/test.do" id="formMain">

提交后,地址栏里出这个连接:
..../kaikei/index.do
怎么转换成它了?

经过查找,index.do在一个class里(UrlPatterns.INDEX = "index.do";)
相关代码:
common.jsp:
if (!com.hitachijoho.keiri.kaikei.web.util.WebUtil.isValidLogin(request)) {
response.sendRedirect(response.encodeRedirectURL(com.hitachijoho.keiri.kaikei.web.util.UrlPatterns.INDEX));
return;
}

coolsboy
2003-04-16 15:46

生成HTML后:
<form name="loginForm" method="post" action="/kaikei/login.do" id="formMain">

jxb8901
2003-04-17 12:12

你要跟踪页面流程一步一步调试.login.jsp中的action="/login.do"会被struts的标签自动转换成"/kaikei/login.do", 但common.jsp中的url="login.do"就不会被转换, 你看问题是不是出在这里, 总之顺着这个思路查一下, 一定能找到问题所在.