Shane Courtrille
Shane Courtrille

Reputation: 14097

How to build an action url in a Struts 2 action?

I have an Action that returns URLs which need to call another Struts2 action. In a JSP I would do <s:url>. Is there something equivalent to this that I can call inside of the action?

Upvotes: 2

Views: 1787

Answers (4)

Steve Gevers
Steve Gevers

Reputation: 46

Since struts is creating your action class, simply use the Inject annotation and have struts tell you!

@Inject
public void setActionMapper(ActionMapper mapper) {
    this.actionMapper = mapper;
}

Upvotes: 3

Vinay Lodha
Vinay Lodha

Reputation: 2223

You can use Action Chaining... All you will do is you will call another action.

Upvotes: 0

Steven Benitez
Steven Benitez

Reputation: 11055

You will probably need to construct the URL yourself inside of your action. One thing you may want to look at is org.apache.struts2.components.URL. This is the class that is used by the s:url tag to create the URL, although it may just be easier to create the URL yourself.

Upvotes: 0

Related Questions