I tried out all the possible solution available on the internet.

error :

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [validateLogin] associated with context path [/LoginApplication].

struts.xml file

<?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="hello" extends="struts-default">

      <action name="validateLogin" 
            class="com.example.login.ValidationAction"
            method="execute">
            <result name="success">/result.jsp</result>
      </action>
   </package>
</struts>

index.jsp

<form action="validateLogin">
        <table>
            <tr>
                <td><label for="username">Username</label></td><td><input type="text" name="username"></td>
            </tr>
            <tr>
                <td><label for="password">Password</label></td><td><input type="password" name="password"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="Login"></td>
            </tr>
        </table>
    </form>
3

There are 3 best solutions below

0
On

This error comes mostly when the package structure is not made correctly.

If the web.xml file and struts.xml file is created under correct package then both the XML files will be reflected automatically under Configuration files folder structure in Netbeans.

Please refer the screenshot:

0
On

Make sure that struts.xml is in the right directory. If you are using Eclipse, you can follow these steps :

1- Right-click on the project ⇾ properties ⇾ Deployment Assembly.

2- Make the deploy Path of your sources like this: screenshot1

-/Src/main/java : WEB-INF/classes.

-Struts2(library) : WEB-INF/lib.

3- Put the struts.xml in the directory which have a deploy Path withe WEB-INF/classes. For example here you should put it in /src/main/java.screenshot2

1
On

The solution to my problem was a little weird.

i just removed <constant name="struts.devMode" value="true" /> from the struts.xml file

and the program started working properly... and then i placed the same code back again in the struts.xml file and it was still running....