There is no Action mapped for namespace [/] and action name [login] associated with context path [/Struts2Test]
Issues related to: There is no Action mapped for namespace and action name associated with context path
If you use URL to call an action, make sure this URL is mapped to the Struts configuration. To troubleshoot the issue with URL mapping you can use config-browser plugin. Simply add this plugin to your project dependencies and when it's deployed, you can access a website showing you a runtime configuration with available URLs to call the action. For example if you are running Tomcat locally on port 8080 and deployed your application at the context
, then you can access the plugin's URL with
http://localhost:8080/[context]/config-browser/index.action
You can click any action available on the actions page under the namespace on the sidebar. Also note that if your action is not found on the package it might be in the default
package. Struts does additional search in the default
namespace for the action that is not at the namespace mapped from the URL.
Check out the config-browser plugin to debug configuration
issues.To map correctly url to the action two parameters are required: the
action name and namespace.Struts loads xml configuration on startup and it should know the
location of thestruts.xml
. By default it's looking on classpath to
find a file with known name likestruts.xml
. Then it parses document
and creates a runtime configuration. This configuration is used to
find appropriate configuration element for the action url. If no such
element is found during request, the 404 error code is returned with
the message:There is no Action mapped for namespace and action name
.Also this message contains a namespace and action names used to find
the action config. Then you can check your configuration settings instruts.xml
. Sometimes the action name and namespace, stored inActionMapping
point to the wrong action. These values are determined
by theActionMapper
which could have different implementation, used
by plugins.There's also another setting that might affect this mapper and
mapping, but the point is the same if you get this message then URL is
used didn't map any action config in runtime configuration. If you
can't realize which URL you should use, you might try
config-browser plugin to see the list of URLs available to use.
There is no Action mapped for namespace [/] and action name [Test] associated with context path [/TestStruts]. - [unknown location]
Because /TestStruts
is a context path at which deployed your application. It has the same path as namespace in your package. Try
http://localhost:8080/TestStruts/TestStruts/test.action
When URls is rendering from the struts tags it's trying to find a corresponding action configuration. If there's no config found the warning is issued.
Struts Hello world example : There is no Action mapped for namespace [/] and action name error
The struts.xml
configuration file needs to be on the classpath (as opposed to in WEB-INF
).
The linked tutorial assumes a Maven build and states the struts.xml
file should go in src/main/resources
, which will be included in the classpath in Maven builds. Since you're ignoring that part, you'll likely want to put it in the root of your source directory.
HTTP 404 - There is no Action mapped for namespace [/modeldriven] and action name [datosUsuario] associated with context path [/FormularioMD]
The Convention plugin, as the name suggests, works using naming conventions.
It searches for certain packages, and inside them, it looks for actions with certain names, or implementing a specific interface.
From the documentation:
By default, the Convention plugin will find all action classes that
implementcom.opensymphony.xwork2.Action
or whose name ends with the
word Action in specific packages.These packages are located by the Convention plugin using a search
methodology. First the Convention plugin finds packages namedstruts
,
struts2
,action
oractions
. Any packages that match those names are
considered the root packages for the Convention plugin. Next, the
plugin looks at all of the classes in those packages as well as
sub-packages and determines if the classes implement
com.opensymphony.xwork2.Action
or if their name ends withAction
(i.e.
FooAction
)
Since your package is:
package com.java.rmo.controladores;
the Convention plugin won't search for anything inside it.
You have two options:
Refactor your package to include one of the names requested by the plugin, for example:
package com.java.rmo.actions;
Add your package to the list of packages the plugin will scan for actions, as described here .
I'd personally go with the first solution... stick to the default, and avoid yourself possible problems or unwanted side effects.
Related Topics
How to Enumerate All Classes in a Package and Add Them to a List
Calculating Difference in Dates in Java
Where Should I Put the Log4J.Properties File
Why Java.Util.Optional Is Not Serializable, How to Serialize the Object with Such Fields
Calculating All of the Subsets of a Set of Numbers
Java Jtextfield with Input Hint
How to Flatten 2D Array to 1D Array
How to Make Image Appear Randomly Every X Seconds in Java Using Timer
Should I Use String.Isempty() or "".Equals(String)
Hibernate Criteria: Joining Table Without a Mapped Association
"Loading Class Com.Mysql.Jdbc.Driver ... Is Deprecated" Message
Integer.Valueof() VS. Integer.Parseint()
How to Use Jsch for Ssh Key-Based Communication
How to Validate an Xml File Using Java with an Xsd Having an Include
Use Custom Fonts When Creating PDF Using Ireport
Swingworker, Thread.Sleep(), or Javax.Swing.Timer? I Need to "Insert a Pause"