在portlet里成功使用sendRedirect的条件
在spring portlet的过程总发现使用actionResponse.sendRedirect(String url)有时成功有时不成功, 甚是蹊跷.
查阅portlet api后得知sendRedirect不能与一些方法同用, 相信如同在servlet里不能先out.print再sendRedirect一样, 因为outputstream不能打开两遍.
不能一同使用的方法是
setPortletMode setWindowState setRenderParameter setRenderParameters removePublicRenderParamter
由此引发的问题是, sendRedirect不能与很多类或者方法一起使用. 如
spring中的parameterMappingInterceptor, 因为这个handler里主动调用setRenderParameter设置返回render方法的action参数.
这种例子会有很多, 只能使用过程中密切注意.
这里另一篇类似问题的文章, http://forum.springsource.org/showthread.php?t=55857, 是它使我获得灵感.