I hav开发者_开发问答e 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?
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;
}
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.
You can use Action Chaining... All you will do is you will call another action.
Use Struts forwards:
http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.struts.doc/topics/cstrdoc006.html
http://www.mkyong.com/struts/struts-forwardaction-example/
精彩评论