JSF 页面渲染两次?
突然间,我的 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);
}
我做错了什么?
All of a sudden my JSF 2 is rendering every page twice (with Eclipse and Tomcat.) No matter how simple it is. For example:
<!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>
is generating a result that looks like this:
What's going on? What's going on?
If I put more complex stuff in there they also show up on the page twice. I tried restarting and all but no luck. So, what's going on?
Edit:
Thanks for your answer everyone. r0ast3d I did change my web.xml to add a filter, and when I removed the entries the double vision disappeared. But I want the filter... The entries I had are like this:
<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>
This is the doFilter method:
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);
}
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案就在您的
doFilter
方法中。您正在调用chain.doFilter(request, response)
两次。The answer is right there in your
doFilter
method. You are callingchain.doFilter(request, response)
twice.