protected final static String GOTO_PAGE = "goto_page"; protected final static String TIP_PAGE = "/admin/tip"; protected void tip(RequestContext ctx,String message) { try { ctx.redirect(ctx.param(GOTO_PAGE, TIP_PAGE), message); } catch (IOException e) { throw new ActionException(e); } }
我在action处理之后,还有一个统一的处理
但如果在action中就redirect的话,就会导致在统一处理的地方报
java.lang.IllegalStateException: Cannot forward after response has been committed
统一对 action 的代码在:
String gp = req.param(GOTO_PAGE); if(StringUtils.isNotBlank(gp)){ int show=req.param(SHOW, 1); if(show>0){ String message = URLEncoder.encode(req.text(BltScript.SUCCESS), UTF_8); gp=gp+"?message="+message; } req.redirect(gp); }其中goto_page是在form提交时,就就隐藏的一下值。
有两种解决方法:
1、要么在action层不使用redirect形式
2、要么在统一处理的地方使用:
if(!req.response().isCommitted()) req.redirect(gp);
共1条评论