response.sendRedirect not working in Struts2 tiles

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 11:56:22
Quaternion

You are right to suspect your meta tag method as being very ugly.

With struts2 you are returning a tiles result type. This is either defined in your struts.xml or the action is annotated to produce this result.

Your action which you want to redirect should NOT be returning a tiles result type but a redirect/redirectAction type. For one of these results see here: Action redirect in struts.xml

Your action should do all the required processing (if any) and tiles should compose the view. If you really intend to redirect, it is a waste to try to compose any view what so ever.

The question which you pointed to (here) probably still applies in this context. That is you can not redirect if you have written content and you may try to redirect and return before writing any further content but tiles is often composing from several views... and will continue to write to the HTTP response and thus likely null the redirect. If you only have a single jsp composing the view, then I don't know. But once again I would not think to invoke tiles at all.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!