我有一个名为newTest.xhtml的页面,由一个名为NewTest的CDI Bean支持,当用户单击一个按钮时,它应该在backinhg bean中做一些工作并返回到同一页面newTest.xhtml。问题是,当我单击按钮时,浏览器不会刷新页面。当我手动点击刷新然后浏览器刷新页面。我的问题是:在JSF中如何告诉浏览器总是从服务器加载页面而不是缓存
public String doWork() {
//do some work
return "/newTest.xhtml?faces-redirect=true";
}
固定 我已经使用ajax的render =“@ all”
解决了这个问题<h:commandButton >
<f:ajax execute="@all" render="@all"/>
</h:commandButton>
答案 0 :(得分:0)
您可以重定向到请求页面
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.redirect(((HttpServletRequest) externalContext.getRequest()).getRequestURI());