简体   繁体   English

在struts1.2中检索动作映射时出错

[英]error in retrieving mapping for action in struts1.2

im stuck with this error n unable to find whr i went wrong 我陷入了这个错误n找不到我错了

here is code..plz go through it im using myelipse,struts1.2 这是代码..plz使用myelipse,struts1.2进行即时处理

struts-config.xml struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts      Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings>
        <action path="/SwitchAction"  type="org.apache.struts.actions.SwitchAction"/>
 </action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

struts-config-Admin.xml struts-config-Admin.xml

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

   <struts-config>
    <data-sources />
    <form-beans>
        <form-bean name="adminLoginForm" type="Admin.Form.AdminLoginForm" />
        <form-bean name="adminUserCreationForm" type="Admin.Form.AdminUserCreationForm" />


    </form-beans>

    <global-exceptions />
    <global-forwards />
    <action-mappings>
        <action attribute="AdminLoginForm" input="/AdminModule/AdminLogin.jsp"
            name="adminLoginForm" path="/AdminLogin" scope="request"
            type="Admin.Action.AdminLoginAction">
            <set-property property="cancellable" value="true" />
            <forward name="failure" path="/AdminErrorPage.jsp" />
            <forward name="success" path="/AdminHomePage.jsp" />
        </action>
        <action attribute="adminUserCreationForm" input="/AdminModule/AdminUserCreation.jsp"
            name="adminUserCreationForm" path="/AdminUserCreation" scope="request"
            type="Admin.Action.AdminUserCreationAction">
            <set-property property="cancellable" value="true" />
            <forward name="failure" path="/AdminModule/AdminErrorPage.jsp" />
            <forward name="success" path="/AdminModule/AdminSuccessPage.jsp" />
        </action>
    </action-mappings>
</struts-config>

AdminUserCreationAction.java AdminUserCreationAction.java

    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<html>
    <head>
        <base href="<%=basePath%>"    
    </head>

    <body>
        User Creation Page
        <html:form action="/AdminUserCreation">
            AdminName : <html:text property="username"/><html:errors property="username"/><br/>
            Password : <html:password property="password"/><html:errors property="password"/><br/>
            <html:submit/>
        </html:form>
    </body>
</html>

AdminUserCreationForm.java AdminUserCreationForm.java

package Admin.Form;

import org.apache.struts.action.ActionForm;

public class AdminUserCreationForm extends ActionForm {

    private String username;
    private String password;
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}

AdminUserCreation.jsp AdminUserCreation.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> 
    </head>
    <body>
        User Creation Page
        <html:form action="/AdminUserCreation">
            AdminName : <html:text property="username"/><html:errors property="username"/><br/>
            Password : <html:password property="password"/><html:errors property="password"/><br/>
            <html:submit/>
        </html:form>
    </body>
</html>

error im getting in browser 错误即时通讯进入浏览器

 type Exception report

     message 

     description The server encountered an internal error () that prevented it from fulfilling this request.

     exception 

     org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /AdminUserCreation
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

     javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /AdminUserCreation
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
    org.apache.jsp.AdminModule.AdminUserCreation_jsp._jspService(AdminUserCreation_jsp.java:114)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

     javax.servlet.jsp.JspException: Cannot retrieve mapping for action /AdminUserCreation
    org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:759)
    org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:443)
    org.apache.jsp.AdminModule.AdminUserCreation_jsp._jspx_meth_html_005fform_005f0(AdminUserCreation_jsp.java:131)
    org.apache.jsp.AdminModule.AdminUserCreation_jsp._jspService(AdminUserCreation_jsp.java:104)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


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

msg im gettng in console 控制台中的msg im gettng

 Servlet.service() for servlet jsp threw exception
 javax.servlet.jsp.JspException: Cannot retrieve mapping for action /AdminUserCreation
 at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:759)
    at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:443)
    at org.apache.jsp.AdminModule.AdminUserCreation_jsp._jspx_meth_html_005fform_005f0(AdminUserCreation_jsp.java:131)
    at org.apache.jsp.AdminModule.AdminUserCreation_jsp._jspService(AdminUserCreation_jsp.java:104)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

there is something a bit odd here (though it may not be the only cause of the problem) : 这里有些奇怪(尽管可能不是导致问题的唯一原因):

in your struts config file, you have defined 在您的struts配置文件中,您已经定义了

<action attribute="adminUserCreationForm" .....
            type="Admin.Action.AdminUserCreationAction">

which implies that class AdminUserCreationAction should be found under the Admin.Action package. 这意味着应在Admin.Action包下找到AdminUserCreationAction类。

however, your AdminUserCreationAction class is declared under Admin.Form package : 但是,您的AdminUserCreationAction类在Admin.Form包下声明:

package Admin.Form;
public class AdminUserCreationForm ...

please try to use the same package name in both cases. 在这两种情况下,请尝试使用相同的软件包名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM