突然之间,我的JSF 2渲染了每一页两次(使用Eclipse和Tomcat。)无论多么简单。例如:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:body>
<h:outputText value="What's going on?"></h:outputText>
</h:body>
生成的结果如下所示:
发生了什么事?这是怎么回事?
如果我把更复杂的东西放在那里,他们也会在页面上出现两次。我尝试重新启动,但没有运气。发生什么了?
感谢大家的回答。 r0ast3d我确实更改了我的web.xml以添加过滤器,当我删除条目时双重视觉消失了。但我想要过滤器......我的条目是这样的:
<filter>
<filter-name>dontCache</filter-name>
<filter-class>com.company.auctions.ui.DisableCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>dontCache</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
这是doFilter方法:
public void doFilter(ServletRequest request, ServletResponse res, FilterChain chain) throws IOException, ServletException {
// TODO Auto-generated method stub
// place your code here
System.out.println("DisableCacheFilter.doFilter CALLED");
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);
// pass the request along the filter chain
chain.doFilter(request, response);
}
我做错了什么?
答案 0 :(得分:3)
答案就在您的doFilter
方法中。您正在拨打chain.doFilter(request, response)
两次。