struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hernán <heam...@gmail.com>
Subject Re: Struts2 RedirectAction Situation
Date Tue, 17 Jul 2012 14:18:20 GMT
Thank you Joseph for your reply, you are right, replacing the String Spring
bean solves the problem (as you can see in the following snippet)

    <!--
    <beans:bean id="successLogoutUrl" class="java.lang.String">
        <beans:constructor-arg value="/" />
    </beans:bean>
    -->
    <beans:bean id="logoutFilter"
class="org.springframework.security.web.authentication.logout.LogoutFilter">
        <beans:constructor-arg value="/">

        </beans:constructor-arg>
        <beans:constructor-arg>
            <beans:list>
                <beans:ref bean="rememberMeServices" />
                <beans:ref bean="securityContextLogoutHandler" />
            </beans:list>
        </beans:constructor-arg>
        <beans:property name="filterProcessesUrl"
value="/logout/j_spring_security_logout"/>
    </beans:bean>

It seems that using a String bean and using
struts.objectFactory.spring.autoWire=auto in struts.properties
wires the String to every parameter of ServletActionRedirectResult by
constructor. Is this a struts2 bug?

Thank you.

Martin, thank you for your reply as well. However, I don't understand what
you are saying.

On Fri, Jul 13, 2012 at 5:50 PM, Martin Gainty <mgainty@hotmail.com> wrote:

>
> Necesita cambiar a Header con el nombre 'Location' a nuevo URL
> URL page = new URL(hostUrl);
>
>         HttpURLConnection.setFollowRedirects(true);
>         HttpURLConnection urlc = (HttpURLConnection) page.openConnection();
> String token = urlc.getHeaderField("Location");
>
> Martin Gainty
> ______________________________________________
> Jogi és Bizalmassági kinyilatkoztatás/Verzicht und
> Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  Ez az
> üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
> jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
> készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
> semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
> könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
> ezen üzenet tartalma miatt.
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
> From: jmocker@velti.com
> To: user@struts.apache.org
> Subject: Re: Struts2 RedirectAction Situation
> Date: Fri, 13 Jul 2012 17:58:45 +0000
>
>
>
>
>
>
> 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"/>
>     </bean>
>
>
>
>
> 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.
>
>
>
>   --joe
>
>
>
>
>
>
>
>
>
>
> Joseph
> Mocker  |  Senior Software Architect
>
>
> t +1.650.566.7033   m +1.408.676.6625
>
> e jmocker@velti.com   @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>
>
>
>
>    <beans:bean id="logoutFilter"
>
>
> class="org.springframework.security.web.authentication.logout.LogoutFilter">
>
>        <beans:constructor-arg ref="successLogoutUrl" />
>
>        <beans:constructor-arg>
>
>            <beans:list>
>
>                <beans:ref bean="rememberMeServices" />
>
>                <beans:ref bean="securityContextLogoutHandler" />
>
>            </beans:list>
>
>        </beans:constructor-arg>
>
>        <beans:property name="filterProcessesUrl"
>
> value="/logout/j_spring_security_logout"/>
>
>    </beans:bean>
>
>
>
>
>
> 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:
>
>
>
> struts.xml
>
>
>
>        <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>
>
>            </result>
>
>        </action>
>
>
>
> org.apache.struts2.dispatcher.ServletActionRedirectResult.java
>
>
>
>    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));
>
>
>
>        setLocation(tmpLocation);
>
>
>
>        super.execute(invocation);
>
>    }
>
>
>
> org.apache.struts2.dispatcher.ServletRedirectResult.java
>
>
>
>    public void execute(ActionInvocation invocation) throws Exception {
>
>        if (anchor != null && !anchor.equalsIgnoreCase("null") &&
>
> !anchor.equalsIgnoreCase("")) {
>
>            anchor = conditionalParse(anchor, invocation);
>
>        }
>
>        super.execute(invocation);
>
>    }
>
>
>
>
>
> Greetings, any comment will be appreciated.
>
>
>
> --
>
> Hernán
>
>
>
>
>
>
>



-- 
Hernán

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