BalusCの回答によると、使用しました
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
私の@PostConstruct方法では、JSFがビューをレンダリングしてユーザーをリダイレクトするのを止めます。ただし、コードを実行しようとするとjava.lang.IllegalStateException、上記の行で例外が発生します。
WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:524)
at StudentManagedBean.CourseSummary.init(CourseSummary.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
更新:@PostConstructメソッドに次の行を追加しました。
System.out.println("INIT " + FacesContext.getCurrentInstance().getExternalContext().isResponseCommitted());
そして私が見たのはINIT true. @PostConstructメソッドが呼び出される前に応答がコミットされることになっているのだろうか?
アドバイスをいただければ大変助かります。