simple singularities

strage situation in struts 2 redirection

Filed under: java, programming — fri13th June 25, 2007 @ 9:41 pm

i need to deliver some parameter when redirecting in struts 2. it’s some what like this..

Action.java
Long id;
public Long getId() {
 return this.id;
}

struts.xml
<action name="saveAction" class="Action" method="save">
     <result name="success" type="redirect">
        <param name="location">url.html?id=${id}</param>
        <param name="parse">true</param>
        <param name="encode">true</param>
      </result>
</action>

and it fairly doens’t work.. like this..
url.html?id=com.cns:ips:war:2.0

what the hell!

i change it to this

Action.java
Long myId;
public Long getMyId() {
 return this.myId;
}

struts.xml
<action name="saveAction" class="Action" method="save">
     <result name="success" type="redirect">
        <param name="location">url.html?id=${myId}</param>
        <param name="parse">true</param>
        <param name="encode">true</param>
      </result>
</action>

and it works fine! please tell me how redirect works in struts? if struts 2 uses id as a reserved variable.. why can i get those documents? there’s so many mystery in struts and java world..

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment