title: HTTP Status 404 - There is no Action mapped for namespace [/] and action name [login] associated with context path [/struts2]
body: <p>I have learned theory of Struts2 and now practicing. Facing problems while executing project.I searched in Google in many ways but could not find result.Please help me. Below is the code.Please help me friends...</p>
  
  <p>Project structure:</p>
  
  <p><img src="https://i.stack.imgur.com/mZlfA.png" alt="Project structure"></p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
  &lt;display-name&gt;struts2&lt;/display-name&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;login.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  </code></pre>
  
  <p></p>
  
  <p>struts.xml</p>
  
  <pre><code>&lt;!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  &lt;struts&gt;
  
  &lt;constant name="resources" value="ApplicationResources" /&gt;
  &lt;constant name="struts.devMode" value="true" /&gt;
  &lt;package name="default" extends="struts-default"&gt;
      &lt;action name="login" class="com.practice.structs.actions.LoginAction"
          method="validateUser"&gt;
          &lt;result name="success"&gt;pages/homepage.jsp&lt;/result&gt;
          &lt;result name="error"&gt;pages/login.jsp&lt;/result&gt;
      &lt;/action&gt;
  
  &lt;/package&gt;
  </code></pre>
  
  <p></p>
  
  <p>LoginAction.java</p>
  
  <pre><code>package com.practice.structs.actions;
  
  import com.opensymphony.xwork2.ActionSupport;
  
  public class LoginAction extends ActionSupport {
  private String userName;
  private String password;
  public String validateUser(){
      if(this.userName.equalsIgnoreCase("abc") &amp;&amp; this.password.equalsIgnoreCase("abc"))
      {
          return "success";
      }else{
          addActionError(getText("error.login"));
          return "error";
      }
  }
  
  /**
   * @return the userName
   */
  public String getUserName() {
      return userName;
  }
  /**
   * @param userName the userName to set
   */
  public void setUserName(String userName) {
      this.userName = userName;
  }
  /**
   * @return the password
   */
  public String getPassword() {
      return password;
  }
  /**
   * @param password the password to set
   */
  public void setPassword(String password) {
      this.password = password;
  }
  
  
  }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;title&gt;Login page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;H1&gt;&lt;I&gt;Login Page&lt;/I&gt;&lt;/H1&gt;
  &lt;s:actionerror /&gt;
  &lt;s:form action="login.action" method="post"&gt;
      &lt;s:textfield name="uname" key="label.username" size="20"/&gt;
      &lt;s:password name="password" key="label.password" size="20"/&gt;
      &lt;s:submit method="execute" key="label.login" align="center"/&gt;
  &lt;/s:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>homepage.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@taglib prefix="s" uri="/struts-tags" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Home Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;H2&gt;&lt;I&gt;Welcome&lt;/I&gt;&lt;/H2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>