有一个页面:test.faces,我通过URL后面加上参数后变为:test.faces?code=1
当我通过 test.faces?code=1 这个URL访问页面时,java bean就会自动被触发创建!
在JAVA BENA里面通过读取参数code的值,当code小于100时,服务器就直接返回这个test.faces的页面,如果code大于100时就自动跳转去错误页面!
public static void redirectPage(String szPage)
{
FacesContext context = FacesContext.getCurrentInstance();
javax.faces.application.Application app = context.getApplication();
UIViewRoot view = app.getViewHandler().createView(context, szPage);
context.setViewRoot(view);
context.renderResponse();

不知道怎么实现!
以上的尝试过,不行,不知道为什么!