There is no Action mapped for namespace [/] and Action name [XX] associated with context path ...

Source: Internet
Author: User

Long time no use struts, today practiced a simple application, there have been some unexpected problems, due to this reason has been reported 404

First of all, my directory structure is such a drop

This is configured in Web. xml

<web-app>
<display-name>archetype Created Web application</display-name>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>/WEB-INF/welcome.jsp</welcome-file>
</welcome-file-list>
</web-app>

Very simple, struts intercept all, plus a welcome page

Struts.xml is like this.

<struts>
<constant name= "Struts.devmode" value= "true" ></constant>
<constant name= "struts.i18n.encoding" value= "UTF-8" ></constant>
<constant name= "Struts.locale" value= "ZH_CN" ></constant>

<package name= "Default" namespace= "/web-inf/pages" extends= "Struts-default" >
<action name= "Index" >
<result>login.jsp</result>
</action>

<action name= "Login" class= "Com.tjjy.struts.Login" >
<result name= "SUCCESS" >ok.jsp</result>
</action>
</package>

</struts>

There's only one namespace here.

Welcome Page Configuration Easier

<body>
Welcome!!!!!!!!!!!!!!!
<a href = "Index.action" > Point me </a>
</body>

The idea is: Start the server, first enter the Welcome page and then go to the landing page, and then login successfully

But the runtime is

There is no action mapped for namespace [/] and Action name [] associated with context path [/strutstest]. -[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:39)
At Com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy (defaultactionproxyfactory.java:58)
At Org.apache.struts2.dispatcher.Dispatcher.serviceAction (dispatcher.java:536)
At Org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction (executeoperations.java:77)
At Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter ( strutsprepareandexecutefilter.java:91)
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:503)
At Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:170)
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:421)
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:314)
At Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145)
At Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615)
At Org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run (taskthread.java:61)
At Java.lang.Thread.run (thread.java:744)

Say I can't find the action I want to request under this namespace

At first, I thought there was a problem with the struts interceptor.

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

<package name= "Default" namespace= "/web-inf/pages" extends= "Struts-default" >
<action name= "Index.action" >
<result>login.jsp</result>
</action>

The results are still the same as above, it is obvious that the problem is not here, but obviously error is said to find the action, it must be a URL problem, after a period of time, the attempt to write a variety of URLs, have failed, change the angle is not in the Welcome page began to problem

This is a very stupid, very low-level problem is that the Welcome page path error, instead:

<welcome-file-list>
<welcome-file>/WEB-INF/welcome.jsp</welcome-file>
</welcome-file-list>

Success, and try the above changed URL way, are no problem, the knowledge can not blindly pursue new, to warm so know new, time is not even the foundation of all forget

There is no Action mapped for namespace [/] and Action name [XX] associated with context path ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.