找不到action,在线等待

szpqq 2004-10-14 11:05:59
我提交页面时提示找不到对应的action
type Status report

message /loginAction.do

description The requested resource (/loginAction.do) is not available.


具体源码大致如下:

一、test.jsp 主页面
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*"
import="javax.sql.*"
import="javax.naming.*"
errorPage="" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="LoginActionForm" action="/loginAction.do" >

<p>用户名:
<input type="text" name="c_name">
</p>

<p>密码:
<input type="text" name="c_password">
</p>
<input type="submit" name="Submit" value="提交">
<p>  </p>
</form>
</body>
</html>


二、struts-config.xml的配置

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">


<struts-config>


<!-- ========== Data Source Configuration =============================== -->


<!-- ========== Form Bean Definitions =================================== -->

<form-beans>
<form-bean
name="LoginActionForm"
type="kk.test.LoginActionForm"/>
</form-beans>


<!-- ========== Global Forward Definitions ============================== -->


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

<action-mappings>
<action
input="/error.jsp"
path="/loginAction"
type="kk.test.loginAction"
name="LoginActionForm"
scope="request"
input="/error.jsp">
<forward
name="Success"
path="/test.jsp"/>
<forward
name="failure"
path="/error.jsp"/>
</action>
</action-mappings>
<message-resources parameter="resources.application"/>

</struts-config>

三、web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>



<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>


<!-- Standard Action Servlet Configuration (with debugging) -->

<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>debug</param-name>

<param-value>2</param-value>

</init-param>

<init-param>

<param-name>detail</param-name>

<param-value>2</param-value>

</init-param>
<load-on-startup>2</load-on-startup>

</servlet>


<!-- Standard Action Servlet Mapping -->

<servlet-mapping>

<servlet-name>action</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>


<!-- Struts Tag Library Descriptors -->
<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>
</web-app>

当我点击提交时出现上面错误提示,在线等待,解决即给分,谢谢
...全文
101 点赞 收藏 15
写回复
15 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
szpqq 2004-10-14
path="/loginAction"不这样设置的吗?它不是跟action="/loginAction.do"对应吗?
type="kk.test.loginAction"路径肯定没错,因为还有另外两个class跟它放在一块,并且在页面中的
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*"
import="javax.sql.*"
import="kk.test.*"
import="javax.naming.*"
errorPage="" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<html:base/>
</head>
<body>
<html:errors/>
<%
try{
LoginActionForm info = new LoginActionForm();
info.setC_name("0002");
loginDBBen dbean = new loginDBBen();
dbean.setInfo(info);
if (dbean.getlst()) {
out.println("有数据据");
}
}catch(Exception e){
System.out.println(e);
}
%>
</body>
</html>
运行没错
麻烦大家帮忙看看,分不够再加
回复
jionghan3855 2004-10-14
path="/loginAction"
type="kk.test.loginAction"
path的路径对这没
回复
szpqq 2004-10-14
换了还是一样的,它可能就是找不到配置
Cannot find ActionMappings or ActionFormBeans
回复
bp69 2004-10-14
两个<?xml version="1.0" encoding="ISO-8859-1"?>
换成:
<?xml version="1.0" encoding="UTF-8" ?>试试
回复
szpqq 2004-10-14
其它设置应该可以吧,因为我测试下面的页面没问题
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*"
import="javax.sql.*"
import="pqq.test.*"
import="javax.naming.*"
errorPage="" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<html:base/>
</head>
<body>
<html:errors/>
<%
try{
LoginActionForm info = new LoginActionForm();
info.setC_name("0002");
loginDBBen dbean = new loginDBBen();
dbean.setInfo(info);
if (dbean.getlst()) {
out.println("有数据据");
}
}catch(Exception e){
System.out.println(e);
}
%>
</body>
</html>


上面没问题,但是如果在那段jsp上面加上
<html:form action="/loginAction.do">
<p>用户名:
<input type="text" name="c_name">
</p>

<p>密码:
<input type="text" name="c_password">
</p>
<input type="submit" name="Submit" value="提交">
<p>  </p>
</html:form>

就说找不到配置吧
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.test_jsp._jspx_meth_html_form_0(test_jsp.java:157)
org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


那两配置文件都放在web-inf目录下了
回复
fashchina 2004-10-14
你直接用html标签写就行,把<html:form></html:form>
你也可以改(如果有虚拟目录)<form name="LoginActionForm" action="/loginAction.do" >
改成<form name="LoginActionForm" action="/虚拟目录/loginAction.do">
回复
fashchina 2004-10-14
有没有虚拟目录呀?
回复
jionghan3855 2004-10-14
<form name="LoginActionForm" action="/loginAction.do" >
改成<form name="LoginActionForm" action="loginAction.do">试试
回复
szpqq 2004-10-14
帮忙看看啊,up有分
回复
bp69 2004-10-14
看看你的web.xml,跟这个有什么不同
回复
bp69 2004-10-14
<?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>your project</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>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>
回复
szpqq 2004-10-14
up
回复
szpqq 2004-10-14
感觉TOMACT启动时struts-config.xml没读上似的,
<message-resources parameter="resources.application"/>应该也没错,但在页面上
<bean:message key="welcome.ok"/>也冒错,资源文件中有这行
welcome.ok=Welcome!!!!
回复
bp69 2004-10-14
<html:form action="/loginAction.do">--><html:form action="/loginAction.do" method="POST">
回复
szpqq 2004-10-14
up有分,下午结帐
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-10-14 11:05
社区公告
暂无公告