0

For example, I have an URL: /test.action?a=1&b=2 Now I want in jsp page use to get only "a=1&b=2" out of the URL, how to do this?

1 Answer 1

0

Action Code

public class MyAction extends ActionSupport {
    private String a;
     private String a;

    public String execute() throws Exception {
        // do something here
        return SUCCESS;
    }

    public String getA() {
        return a;
    }

    public void setA(final String a) {
        this.a= a;
    }

 public String getB() {
        return b;
    }

    public void setB(final String b) {
        this.a= a;
    }
}

Using Struts tags:

<s:property value="a"/>
<s:property value="b"/>

Still i am not sure what exactly is your requirement as its not very clear from your question

Just a side note <s:url> This tag is used to create a URL
3
  • I want to create an url as a property to set a field, but I just need the parameters part in <s:url>. So here I just want to know is that possible only use struts tag to extract those parameters.
    – xmurobi
    Nov 25, 2011 at 14:21
  • 1
    you can set them in some hidden text fields and can use them where ever you want Nov 25, 2011 at 14:25
  • I agree with umesh to use <s:property> if you require them on the page, else use hidden variables to transport them wherever you want. Dec 11, 2011 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.