1. <i id='opfiE'><tr id='opfiE'><dt id='opfiE'><q id='opfiE'><span id='opfiE'><b id='opfiE'><form id='opfiE'><ins id='opfiE'></ins><ul id='opfiE'></ul><sub id='opfiE'></sub></form><legend id='opfiE'></legend><bdo id='opfiE'><pre id='opfiE'><center id='opfiE'></center></pre></bdo></b><th id='opfiE'></th></span></q></dt></tr></i><div id='opfiE'><tfoot id='opfiE'></tfoot><dl id='opfiE'><fieldset id='opfiE'></fieldset></dl></div>
    <tfoot id='opfiE'></tfoot>
      <bdo id='opfiE'></bdo><ul id='opfiE'></ul>

    <small id='opfiE'></small><noframes id='opfiE'>

    1. <legend id='opfiE'><style id='opfiE'><dir id='opfiE'><q id='opfiE'></q></dir></style></legend>

      关于 Struts2 中的动作映射 - 没有动作映射

      Regarding the Action Mapping in Struts2 - There is no Action mapped(关于 Struts2 中的动作映射 - 没有动作映射)
        <tbody id='hRdBW'></tbody>

        <tfoot id='hRdBW'></tfoot>

        <legend id='hRdBW'><style id='hRdBW'><dir id='hRdBW'><q id='hRdBW'></q></dir></style></legend>

          <i id='hRdBW'><tr id='hRdBW'><dt id='hRdBW'><q id='hRdBW'><span id='hRdBW'><b id='hRdBW'><form id='hRdBW'><ins id='hRdBW'></ins><ul id='hRdBW'></ul><sub id='hRdBW'></sub></form><legend id='hRdBW'></legend><bdo id='hRdBW'><pre id='hRdBW'><center id='hRdBW'></center></pre></bdo></b><th id='hRdBW'></th></span></q></dt></tr></i><div id='hRdBW'><tfoot id='hRdBW'></tfoot><dl id='hRdBW'><fieldset id='hRdBW'></fieldset></dl></div>

          <small id='hRdBW'></small><noframes id='hRdBW'>

              <bdo id='hRdBW'></bdo><ul id='hRdBW'></ul>
              1. 本文介绍了关于 Struts2 中的动作映射 - 没有动作映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试运行我的 struts 应用程序,但我收到错误操作未映射我已经看到命名空间是正确的,但仍然收到错误?

                I am trying to run my struts application but I am getting a error action is not mapped I have seen the namespace it is correct but still getting the error?

                struts.xml:

                <?xml version="1.0" encoding="UTF-8" ?>
                <!DOCTYPE struts PUBLIC
                    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                    "http://struts.apache.org/dtds/struts-2.0.dtd">
                
                <struts>
                
                     <constant name="struts.enable.DynamicMethodInvocation" value="false" />
                    <constant name="struts.devMode" value="false" />
                
                    <include file="register.xml"/>
                
                    <!-- Add packages here -->
                
                </struts>
                

                还有我的register.xml:

                <?xml version="1.0" encoding="UTF-8" ?>
                <!DOCTYPE struts PUBLIC
                        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
                        "http://struts.apache.org/dtds/struts-2.0.dtd">
                
                <struts>
                
                     <package name="register" namespace="/" extends="struts-default">
                
                        <action name="Register" class="com.struts2.RegisterAction">
                            <result name="input">/register.jsp</result>
                            <result type="redirectAction">register.jsp</result>
                        </action>
                
                        <!-- Add actions here -->
                    </package>
                </struts>
                

                我正在验证我的注册页面和验证 XML,如下所示

                I am validating my register page and the validation XML as follows

                RegisterAction-validation.xml:

                <!DOCTYPE validators PUBLIC
                        "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
                        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
                
                <validators>
                    <field name="username">
                        <field-validator type="requiredstring">
                            <message key="requiredstring"/>
                        </field-validator>
                    </field>
                    <field name="password">
                        <field-validator type="requiredstring">
                            <message key="requiredstring"/>
                        </field-validator>
                        <field-validator type="stringlength">
                            <param name="minLength">6</param>
                            <param name="trim">true</param>
                            <message key="requiredpassword"/>
                        </field-validator>
                    </field>
                    <field name="email">
                        <field-validator type="requiredstring">
                            <message key="requiredstring"/>
                        </field-validator>
                        <field-validator type="email">
                            <message key="requiredemail"/>
                        </field-validator>
                    </field>
                    <field name="gender">
                        <field-validator type="requiredstring">
                            <message key="requiredstring"/>
                        </field-validator>
                    </field>
                    <field name="postalcode">
                        <field-validator type="requiredstring">
                            <message key="requiredstring"/>
                        </field-validator>
                        <field-validator type="regex">
                            <param name="expression"><![CDATA[^d*$]]></param>
                            <message key="requiredinteger"/>
                        </field-validator>
                    </field>
                </validators>
                

                而我的register.jsp如下:

                <%@ page contentType="text/html; charset=UTF-8" %>
                <%@ taglib prefix="s" uri="/struts-tags" %>
                <html>
                <head>
                    <title>Validation Struts page</title>
                    <s:head/>
                </head>
                
                <body>
                <s:form action="Register">
                    <s:textfield key="username"/>
                    <s:password key="password" />
                    <s:textfield key="email" />
                    <s:select headerKey="" headerValue="Select Gender"
                     key="gender" list="#{'M':'Male','F':'Female'}" />
                    <s:textfield key="postalcode" /> 
                    <s:submit/>
                </s:form>
                </body>
                </html>
                

                我的项目结构如下:

                Strutsvalidation
                --src-->
                    com.struts2(package)-->
                      register.xml,
                      registeraction-validation.xml,
                      javaclasses,
                      struts.xml
                --webcontent-->
                    web-inf-->
                      web.xml
                    register.jsp(in web content)
                

                我收到如下错误?

                There is no Action mapped for action name Register. - [unknown location]
                    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
                    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
                    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
                    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
                    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
                    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
                    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
                    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
                    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
                    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
                    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                    at java.lang.Thread.run(Unknown Source)
                

                推荐答案

                这个配置错误

                <result type="redirectAction">register.jsp</result>
                

                使用

                <result>/register.jsp</result>
                

                redirectAction 结果应该用于重定向到用于定位的动作.

                The redirectAction result should be used to redirect to the action, which name is used for location.

                异常来自您尝试提交时的 s:form 标记.Register 动作实际上封装在命名空间 / 中.这不是默认命名空间,因此应该在 s:form 标签上使用.

                The exception comes from the s:form tag when you tried to submit it. The action Register actually packaged in namespace /. This not a default namespace and therefore should be used on the s:form tag.

                <s:form namespace="/" action="Register">
                

                这篇关于关于 Struts2 中的动作映射 - 没有动作映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
              2. <small id='eiriZ'></small><noframes id='eiriZ'>

                        <tbody id='eiriZ'></tbody>
                      <tfoot id='eiriZ'></tfoot>
                    1. <i id='eiriZ'><tr id='eiriZ'><dt id='eiriZ'><q id='eiriZ'><span id='eiriZ'><b id='eiriZ'><form id='eiriZ'><ins id='eiriZ'></ins><ul id='eiriZ'></ul><sub id='eiriZ'></sub></form><legend id='eiriZ'></legend><bdo id='eiriZ'><pre id='eiriZ'><center id='eiriZ'></center></pre></bdo></b><th id='eiriZ'></th></span></q></dt></tr></i><div id='eiriZ'><tfoot id='eiriZ'></tfoot><dl id='eiriZ'><fieldset id='eiriZ'></fieldset></dl></div>
                      • <bdo id='eiriZ'></bdo><ul id='eiriZ'></ul>
                        • <legend id='eiriZ'><style id='eiriZ'><dir id='eiriZ'><q id='eiriZ'></q></dir></style></legend>