struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Mocker <>
Subject Re: Struts2 RedirectAction Situation
Date Fri, 13 Jul 2012 17:58:45 GMT
Hi Hernán,

I encountered the same problem as what you are describing. I just figured out the cause for
me, which appears to be a String bean I have instantiated in my Spring applicationContext.xml

    <bean id="myBeanName" class="java.lang.String">
    <constructor-arg type="java.lang.String" value="enabled"/>

>From trudging around debug logs it appears Spring is autowiring this by-type as this bean
name is clearly not referenced in ServletActionRedirectResult. Perhaps something similar is
happening for you.


[Velti]<>   Joseph Mocker  |  Senior Software Architect
t +1.650.566.7033   m +1.408.676.6625
e   @Mobclix<>
The leading global technology provider of
mobile marketing and advertising solutions

On Jul 11, 2012, at 7:12 AM, Hernán wrote:

Some days ago I wrote about a problem I had with struts2. As nobody knew
the answer, I solved it but then I forgot to comment about it. So I'll do
it now.
I upgraded a Struts2, Spring, Hibernate Application to the latest version
of struts2 2.3.4, that's way I also upgraded it's corresponding Spring,
Spring security and Tiles dependencies. The web app had spring 2.5.6,
Spring security 2.0 and Tiles 2.0.6. Now it uses spring 3.0.7.RELEASE,
Spring Security 3.1 and Tiles 2.2.2.

The problem I had was with RedirectAction Result, in a nutshell: whenever
struts2 redirected an action, it added !Something#Something at the end of
the correct action I wanted to redirect. As you should know these are the
method and anchor parameters of RedirectAction result... The thing is that
this "Something" comes from Spring Security 3.1 (the same happened with
Spring Security 3.0 as I tried it)

   <beans:bean id="successLogoutUrl" class="java.lang.String">
       <beans:constructor-arg value="Something" />

   <beans:bean id="logoutFilter"
       <beans:constructor-arg ref="successLogoutUrl" />
               <beans:ref bean="rememberMeServices" />
               <beans:ref bean="securityContextLogoutHandler" />
       <beans:property name="filterProcessesUrl"

For an unknown reason (at least for me). The Struts2 class
ServletActionRedirectResult used this constructor and...

   public ServletActionRedirectResult(String namespace, String actionName,
String method, String anchor) {
       super(null, anchor);
       this.namespace = namespace;
       this.actionName = actionName;
       this.method = method;

the values passed in each parameter where the String "Something" then there
was no way to avoid method and anchor parameters of being added to the
redirected action, that's why I made a patch and solve the problem.
What I did is something childish but efficient, I passed "null" String
value to parameters anchor and method and in the code, if the parameters
were the String "null" I set the parameters to null. I know it's a little
bit weird but it worked for me... Maybe I am doing something wrong. Dunno.
Anyway bear it in mind, maybe I'm wrong, maybe it's a bug. I don't know.

Here goes my Patch Adams Code Snippets:


       <action name="ChangeLocaleTo*Action"
class="changeLocaleTo{1}Action" >
           <interceptor-ref name="i18nStack" />

           <result name="success" type="redirectAction">
               <param name="actionName">${redirectToAction}</param>
               <param name="namespace">${redirectToNamespace}</param>
               <param name="method">null</param>
               <param name="anchor">null</param>

   public void execute(ActionInvocation invocation) throws Exception {
       actionName = conditionalParse(actionName, invocation);
       if (namespace == null) {
           namespace = invocation.getProxy().getNamespace();
       } else {
           namespace = conditionalParse(namespace, invocation);
       if (method == null || method.equalsIgnoreCase("null")) {
           method = "";
       } else {
           method = conditionalParse(method, invocation);

       String tmpLocation = actionMapper.getUriFromActionMapping(new
ActionMapping(actionName, namespace, method, null));



   public void execute(ActionInvocation invocation) throws Exception {
       if (anchor != null && !anchor.equalsIgnoreCase("null") &&
!anchor.equalsIgnoreCase("")) {
           anchor = conditionalParse(anchor, invocation);

Greetings, any comment will be appreciated.


  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message