问题描述
当我使用Omnifaces GzipResponseFilter(仅在Glassfish中)时,尝试使用h:commandLink重定向JSF操作中的页面时出现错误.
I get an error when I try to redirect a page in JSF action with a h:commandLink when I use the Omnifaces GzipResponseFilter (only in Glassfish).
异常:java.lang.IllegalStateException:当前状态= FLUSHED,新状态= CODING_END
Exception: java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
环境玻璃鱼3Omnifaces 1.7(GzipResponseFilter)Mojarra 2.1.27JDK 6
EnvironmentGlassfish 3Omnifaces 1.7 (GzipResponseFilter)Mojarra 2.1.27JDK 6
web.xml
<filter>
<filter-name>gzipResponseFilter</filter-name>
<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gzipResponseFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
MyBean.doAction()
MyBean.doAction()
Faces.redirect("anotherPage.jsf");
page.xhtml
page.xhtml
<h:commandLink action="#{myBean.doAction()}">Click</h:commandLink>
该问题仅在我在Tomcat中测试过的Glassfish中发生并且有效.
如果删除GzipResponseFilter声明,重定向将在两台服务器上正常工作.
The problem happens only in Glassfish, I tested in Tomcat and it works.
If I remove the GzipResponseFilter declaration, the redirect works normally on both servers.
您知道这是Omnifaces还是我的代码中的错误?预先感谢.
Do you know if it's a bug on Omnifaces or in my code?Thanks in advance.
堆栈跟踪
java.lang.IllegalStateException: Current state = FLUSHED, new state = CODING_END
at java.nio.charset.CharsetEncoder.throwIllegalStateException(CharsetEncoder.java:951)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:537)
at sun.nio.cs.StreamEncoder.flushLeftoverChar(StreamEncoder.java:223)
at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:282)
at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:130)
at java.io.OutputStreamWriter.close(OutputStreamWriter.java:216)
at org.omnifaces.io.ResettableBufferedWriter.close(ResettableBufferedWriter.java:98)
at java.io.PrintWriter.close(PrintWriter.java:295)
at org.omnifaces.servlet.HttpServletResponseOutputWrapper.close(HttpServletResponseOutputWrapper.java:149)
at org.omnifaces.servlet.GzipHttpServletResponse.close(GzipHttpServletResponse.java:133)
at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:150)
at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
推荐答案
我们无法解决重定向问题,但是当我在f中使用"h:commandLink"时,Faces.redirect()可以正常工作:阿贾克斯当在常规的"h:commandLink",init或preRender方法上调用Faces.redirect()时,该失败.我将打开Omnifaces问题进行讨论.
We can't get solve the problem with the redirection, but the Faces.redirect() works correctly when I use a "h:commandLink" with f:ajax.The Faces.redirect() fails when it is called on a regular "h:commandLink", init or preRender method.I'll open an Omnifaces issue for discuss.
这篇关于Omnifaces GzipResponseFilter和页面重定向的问题(仅适用于Glassfish)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!