为什么我的Struts多模块总是提示:Cannot retrieve mapping for action /loginAction

Henc 2006-04-17 02:27:53
俺是菜鸟,做了一个Struts多模块,但每次都是提示
“Cannot retrieve mapping for action /loginAction”这样的问题,
不知道如何解决,请各位帮下忙,谢谢!

文件结构如下:
\--
|--home
|-- index.jsp
|-- login.jsp
|--WEB-INF
|--class
|-- (*.class文件)
|--home
|-- struts-config.xml
|-- struts-config.xml
|-- web.xml
//---------------------------------------------
//---------------------------------------------
//---------------------------------------------
//**** login.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<HTML>
<HEAD>
<TITLE></TITLE>
<html:base/>
</HEAD>
<BODY>
<html:form action="/loginAction.do" >
<input type="hidden" name="action" value="login">
<TABLE border="0" width="579" height="408" align="center">
<tr height="85%">
<td></td>
<td></td>
<td></td>
</tr>

<TR>
<TH align="right"><bean:message key="login.jsp.prompt.userID"/></TH>
<td align="left"><html:text property="userID" value=""/></td>

<TH align="left"><bean:message key="login.jsp.prompt.password"/></TH>
<TD align="left"><html:password property="password" value=""/></TD>

<TD align="left">
<html:submit><bean:message key="login.jsp.prompt.submit"/></html:submit>
</TD>

</TR>
</TABLE>
</html:form>
</BODY>
</HTML>
//---------------------------------------------
//---------------------------------------------
//---------------------------------------------
//*** web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>ReportSys</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/home</param-name>
<param-value>/WEB-INF/home/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
</web-app>
//---------------------------------------------
//---------------------------------------------
//---------------------------------------------
//*** WEB-INF\home\struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="com.eec.reportsys.safe.form.LoginForm" />
</form-beans>
<action-mappings>
<action name="LoginForm" path="/loginAction" scope="request" type="com.eec.reportsys.safe.action.LoginAction" validate="true" >
<forward name="success" cpath="/index.jsp"/>
<forward name="faile" cpath="/login.jsp"/>
</action>
</action-mappings>
</struts-config>
//---------------------------------------------
//---------------------------------------------
//---------------------------------------------
******************WEB-INF\struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<global-forwards>
<forward name="home" path="/home/login.jsp" />
</global-forwards>
<message-resources parameter="resources.ApplicationResources" />
</struts-config>



//---------------------------------------------
现在不知道如何实现模块之间的切换,不知道要如何配置,
请各位帮看看如何修改,TKS!

...全文
335 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
JaredJared 2006-04-18
  • 打赏
  • 举报
回复
把<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/home</param-name>
<param-value>/WEB-INF/home/struts-config.xml</param-value>
</init-param>
合成在一去看看
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/home/struts-config.xml</param-value>
</init-param>
Marcus-Z 2006-04-17
  • 打赏
  • 举报
回复
在你的配置文件里加入全局或局部的<forward>元素,如
<forward name="home" path="loginAction.do" contextRelative="true" redirect="true"/>
Henc 2006-04-17
  • 打赏
  • 举报
回复
RE:hulians4800(ee)
如果把home下面的配置文件放到web-ing下的struts-config.xml下去的话,那就是正确的。
dreamover 2006-04-17
  • 打赏
  • 举报
回复
你先把home下的配置内容拿到web-inf下的配置文件里试一下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="com.eec.reportsys.safe.form.LoginForm" />
</form-beans>
<action-mappings>
<action name="LoginForm" path="/loginAction" scope="request" type="com.eec.reportsys.safe.action.LoginAction" validate="true" >
<forward name="success" cpath="/index.jsp"/>
<forward name="faile" cpath="/login.jsp"/>
</action>
</action-mappings>
<global-forwards>
<forward name="home" path="/home/login.jsp" />
</global-forwards>
<message-resources parameter="resources.ApplicationResources" />
</struts-config>
hulians4800 2006-04-17
  • 打赏
  • 举报
回复
<action
attribute="LoginForm"
input="/login.jsp"
name="LoginForm"
path="/loginAction"
scope="request"
validate="false"
type="com.eec.reportsys.safe.action.LoginAction" />
这样
hulians4800 2006-04-17
  • 打赏
  • 举报
回复
<action
attribute="LoginForm"
input="login.jsp"
name="LoginForm"
path="/loginAction"
scope="request"
validate="false"
type="com.eec.reportsys.safe.action.LoginAction" />
这里改成这样试试
Henc 2006-04-17
  • 打赏
  • 举报
回复
怎么没人帮忙亚。。。。
Henc 2006-04-17
  • 打赏
  • 举报
回复
改为
<html:form action="loginAction.do" >也不行,它也是一样提示:
Cannot retrieve mapping for action /loginAction
会不会是WEB-INF\home\struts-config.xml有什么地方设置不对?
imA 2006-04-17
  • 打赏
  • 举报
回复
<html:form action="/loginAction.do >

改为
<html:form action="loginAction.do" >

试试

62,614

社区成员

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

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