【发布时间】:2012-05-31 11:27:28
【问题描述】:
我正在尝试从 JSF 中实现 301 重定向,但是当我对其进行 firebug 时,我总是看到正在执行 302。有人能告诉我如何改变下面的方法来完成 301 吗?
/**
* Redirect to specified destination url
*
* @param destination
*/
public static void permanentRedirect(String destination) {
final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
try {
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
if (!response.isCommitted()) {
externalContext.redirect(destination);
}
} catch (IOException e) {
LOGGER.debug("Could not redirect to " + destination);
}
}
【问题讨论】:
标签: jsf redirect jsf-2 http-status-code-301