java 没有为namespace /和action name HelloWorldMap的Action

8yoxcaq7  于 2022-12-02  发布在  Java
关注(0)|答案(3)|浏览(224)

我正在尝试运行一个简单的struts 2 HelloWorld应用程序,当我运行它时,显示“没有为namespaceMap的Action/和action名称HelloWorld。有人能帮忙吗?”

WARNING: Could not find action or result
There is no Action mapped for namespace / and action name HelloWorld. - [unknown location]
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
63lcw9qa

63lcw9qa1#

  • 〉检查操作是否Map到struts文件中-〉jsp中的操作名称,struts.xml中的名称和操作类的名称是否完全相同-〉struts-config.xml中的操作Map是否在某个包下,然后在url中包含该包(例如,在提交表单时,url必须包含包的名称)
jchrr9hc

jchrr9hc2#

更常见的情况是,struts的操作名出错了,即使struts.xml没有任何问题,问题也是jsp文件中缺少了标记lib定义。

n7taea2i

n7taea2i3#

也许您在struts.xml文件中犯了一个错误。下面是一个示例:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    <package name="default" extends="struts-default">
        <action name="helloWorld" class="controller.HelloWorld">
            <result name="success">/HelloWorld.jsp</result>

        </action>
    </package>
</struts>

如果您以这种方式执行此操作,只需确保您必须仅通过Action名称从jsp调用Action;您不需要写入.action:这将导致错误。
这可以回答你的问题。

相关问题