Pages Navigation Menu

Coding is much easier than you think

There Is No Action Mapped For Namespace / And Action Name “YourActionName”

There Is No Action Mapped For Namespace / And Action Name “YourActionName”

 
 Problem
 
Many Struts 2 developers have claimed that they had configured the action class properly but a page not found error occurs when we try to access the action class and will get the following error message in the browser(If the developer mode is enabled).

 
** UPDATE: Struts 2 Complete tutorial now available here.
 

Struts has detected an unhandled exception:

Messages: 
There is no Action mapped for namespace / and action name "yourActionName". 

Stacktraces
There is no Action mapped for namespace / and action name "yourActionName". 
- [unknown location]

com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) ...

 

 

Solution

 
The above error message is saying that the action class is not available, it means you are did something wrong in your action class configuration, it may be a namespace error, just double check the name.

Here’s a working action class configuration in struts.xml file, may use for your reference.
 

<?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.devMode" value="true" />
	<package name="default" namespace="/" extends="struts-default">
 
		<action name="myAction" 
			class="com.Simplecode.action.myAction" >
			<result name="success">jsp/my.jsp</result>
		</action>
 
	</package>
</struts>

 

Assume the project root context is “Struts2“, so, you can access the above action via this URL –
http://localhost:8089/Struts2/myAction.action
 
And it will be better if you learn about Struts2 Namespace configuration to avoid this issue

About Mohaideen Jamil


Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • http://faraneshan.com mehdi

    this error occurs when you put struts.xml in a sub folder of classes / or src , some thing like this :