[ 
https://issues.apache.org/jira/browse/WW-4533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14644316#comment-14644316
 ] 

Lukasz Lenart commented on WW-4533:
-----------------------------------

The following discussion
http://markmail.org/message/xyebqzuphxtih37p

> 404 error with @Action("/") when upgrading Struts2 REST 2.1.8 to 2.3.24
> -----------------------------------------------------------------------
>
>                 Key: WW-4533
>                 URL: https://issues.apache.org/jira/browse/WW-4533
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - REST
>    Affects Versions: 2.3.7, 2.3.8, 2.3.12, 2.3.14, 2.3.14.1, 2.3.14.2, 
> 2.3.14.3, 2.3.15, 2.3.15.1, 2.3.15.2, 2.3.15.3, 2.3.16, 2.3.16.1, 2.3.16.2, 
> 2.3.16.3, 2.3.20, 2.3.24
>         Environment: *ix System, Tomcat 6.0.44, Java 1.6
>            Reporter: Julio Aragao
>              Labels: Mapping, Plugin, REST, URL
>             Fix For: 2.3.x
>
>
> I have a web app made using Struts 2 version 2.1.8, and its Convention and 
> REST plugins. I needed to update it to the latest version (2.3.24) but one 
> feature I used to have stopped working. I tracked the versions after 2.1.8, 
> and found out that it was after version 2.3.7 that the problem started to 
> happen. I have created a simple app called “upgradetest" to isolate the 
> problem. Here is the error scenario:
> I have an Action called HomeController, in which I have a method index() that 
> is marked with the @Action(“/“) annotation, so that the root url of the app 
> maps to this method, like below:
> {code:java}
> package upgradetest.web.struts;
> import org.apache.struts2.convention.annotation.Action;
> import org.apache.struts2.rest.RestActionSupport;
> import upgradetest.model.Messages;
> public class HomeController extends RestActionSupport {
>     private Messages messages;
>     public HomeController() {
>     }
>     @Action("/")
>     public String index() {
>         messages = new Messages();
>         return show();
>     }
>     public String show() {
>         return "show";
>     }
>     public Messages getMessages() {
>         return messages;
>     }
> }
> {code}
> Here is my struts.xml file:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>         "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>         "http://struts.apache.org/dtds/struts-2.3.dtd";>
> <struts>
>         <constant name="struts.devMode" value="true" />
>         <package name="upgradetest" extends="struts-default">
>         </package>
>         <constant name="struts.objectFactory" value="spring" />
>         <constant name="struts.custom.i18n.resources" 
> value="global-resources" />
>         <constant name="struts.mapper.class" value="rest" />
>         <constant name="struts.convention.action.suffix" value="Controller"/>
>         <constant name="struts.convention.action.mapAllMatches" value="true"/>
>         <constant name="struts.convention.default.parent.package" 
> value="upgradetest"/>
> </struts>
> {code}
> Normally, by visiting the root url of my app (“/“) in Struts2 2.1.8, the 
> index() method was called, and it then took the user to the desired result. 
> After the upgrade to 2.3.7, the web app is returning a 404 error.  I have 
> investigated the source code and found out that the RestActionMapper of 
> Struts Rest Plugin is returning null in the getMapping method (in the last 
> line of code), something it did not in version 2.1.8. I believe this change 
> was done for some reason so I was wondering:
> Is there a way to map the root url (“/“) to a specific action of mine without 
> having to do a redirect or something like that (because of a SEO requirement 
> I have)? Also, am I doing it the wrong way?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to