开发者

Mapping an struts2 action based on querystring, rather than path name

Is there a way to configure struts 2, so that the dispatcher will use the query开发者_开发技巧string to map the action to invoke?

For example, in the link below, I would like to invoke action blah, not action foo.

http://domain:port/myapp/foo.do?someparameter=blah

Thanks.


I do not think that is possible with any of the default mappers.

It wouldn't be that bad to create an Interceptor that is configured for your foo action that checks the value of someparameter, and either chains or redirects to your blah action.


+1 Jeremy: That can do the magic else if you don't want to create an action just create a kinda dispatcher action which will dispatch your request to certain action based on the value of Query String

For e.g

Foo action execute();

if (querystring="test") {
    setActionName("Test");
    return "next";
}

Based on these control string, you can forward request to certain action.

<result name="next" type="redirectAction">${actionName}</result>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜