问题描述:

I would like to perform a redirection for my JSP page, which the URL will be changed to /folder/mypage.jsp, without losing my request attributes.

Is there any way I can perform this kind of redirection in Struts 2?

<result type="redirect">/folder/mypage.jsp</result>

网友答案:

A dispatcher result type is what you need. When you perform redirection to a JSP page using this type of result the request is dispatched to the resource by forwarding request to the new request. A dispatcher result type is used by default.

<result>/folder/mypage.jsp</result>

In this way you "keep" all attributes from the previous request. Then Struts filter is able to delegate JSP pages to a default servlet instead of action execution, however the action context is created, so you can use Struts tags in JSP.

相关阅读:
Top