0

This is my action class

   package actions;
   import com.opensymphony.xwork2.ActionSupport;
   import bean.UserBean;
   public class UserInsert extends ActionSupport {
   private static final long serialVersionUID = 1L;
   public String execute() throws Exception {
   return "success";
   }
   public static void main(String[] org) {
   }
   }

Here is the index.jsp code

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Developer</title>
    </head>

<body>
    <h1>Login Page</h1>
    <form action="login">
        <table>
            <tr>
                <td><label>User Name / Email</label></td>
                <td><input type="text" /></td>
            </tr>
            <tr>
                <td><label>Password</label></td>
                <td><input type="password" /></td>
            </tr>
            <tr>
                <td></td>
                <td><button type="submit">Login</button></td>
            </tr>
        </table>
    </form>
</body>
</html>

Here is the web.xml code

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                         http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <display-name>Struts Blank</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>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

Here is the struts.xml code

<?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="login" class="actions.UserInsert" method="execute">
            <result name="success">/welcome.jsp</result>
        </action>

    </package>

</struts>

I had followed this link of mkyoung "http://www.mkyong.com/struts2/there-is-no-action-mapped-for-namespace-and-action-name-youractionname/" but getting same error, while “struts.devMode” is turn OFF or “struts.devMode” is turn ON getting same error "There is no Action mapped for namespace / and action name login" If any one had experienced this issue, kindly give your good suggestions. I am using JDK 1.8, Apache Tomcat 8.

1 Answers1

0

try this

Your Action Class

 package actions;
 public class UserInsert {

   public String execute(){
      return "success";
   }
 }

web.xml

sometimes there might be problems in web.xml relating this org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

try pasting this one

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns="http://xmlns.jcp.org/xml/ns/javaee"   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee   http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"   version="3.1">
<display-name>Struts Example</display-name>
   <welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>

   </welcome-file-list>

 <filter>
      <filter-name>struts2</filter-name>
      <filter- class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</fil ter-class>
 </filter>

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

 </web-app>