0

I have to upgrade my struts 1.3 application to struts 2.3.34 in phases, so my application should support both struts 1 and struts 2.

I included below dependencies in pom.xml

   <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.3.34</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts.xwork</groupId>
        <artifactId>xwork-core</artifactId>
        <version>2.3.34</version>
    </dependency>

Web.xml changes

 <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
        <param-name>config</param-name>
        <param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
     </init-param>
 </filter>
 <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
 </filter-mapping>

struts.xml which I created in in src folder

   <?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.action.extension" value="action"/>
<package name="mdn" extends="struts-default" namespace="/">
    <action name="MDN" class="com.mdn.MDNStruts2Action">
        <result name="success">/mdnresponse.jsp</result>
    </action>
</package>
</struts> 

I have created java class MDNStruts2Action.java

 public class MDNProjectStruts2Action extends ActionSupport{
    public String execute(){
      return "success";
    }
 }

when I access the url: jsp/MDN.action throwing 404 error org.apache.struts2.dispatcher.Dispatcher - Could not find action or result: /jsp/MDN.action There is no Action mapped for action name MDN. - [unknown location]

But if I hit the url jsp/MDN.do my old struts 1 code is working without any issues.

Did I configure struts 2 wrongly?

Thanks in advance

sss
  • 19
  • 3

0 Answers0