jsf 的页面导航问题
JSF推荐使用commandButton和commandLink来进行页面间的跳转(利用他们的action属性),可是我在执行了BEAN后,再执行脚本而不是要跳到一个页面,怎么做,我的后台报错Cannot forward after response has been committed
我在BEAN 有如下代码
HttpServletResponse response=(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setContentType( "text/html ");
response.setCharacterEncoding( "UTF-8 ");
PrintWriter out = response.getWriter();
out.println( " <script language= 'javaScript '> parent.extentPosition( ' "+coordinates+ " ');parent.gpshistoryframe1.location.href= 'carhistorysearch.jsf ';parent.document.all.gpscarhistory.style.display = 'none '; </script> ");
out.close();
[解决办法]
别使用commandLink进行跳转(相当于跳转两次),使用commandButton就可以了.