部分响应xml显示在浏览器上,而不是页面本身

部分响应xml显示在浏览器上,而不是页面本身,xml,spring,jsf,primefaces,partial-response,Xml,Spring,Jsf,Primefaces,Partial Response,我目前正在使用Spring和primefaces4.0开发一个JSF应用程序。在重定向到其他页面时,我们会遇到与显示的XML页面而不是页面本身有关的间歇性问题 这似乎与此相似。无论何时发生这种情况,日志中都不会打印错误 部分响应1: <partial-response> <error> <error-name>class java.lang.IndexOutOfBoundsException</error-name>

我目前正在使用Springprimefaces4.0开发一个JSF应用程序。在重定向到其他页面时,我们会遇到与显示的XML页面而不是页面本身有关的间歇性问题

这似乎与此相似。无论何时发生这种情况,日志中都不会打印错误

部分响应1:

<partial-response>
    <error>
          <error-name>class java.lang.IndexOutOfBoundsException</error-name>
          <error-message>
              <![CDATA[ Index: 0, Size: 0 ]]>
          <error-message>
    </error>
</partial-response>
<partial-response>
   <changes>
       <update id="javax.faces.ViewState">-4640542341950585998:4269573232206322924</update>
   </changes>
</partial-response>

类java.lang.IndexOutOfBoundsException
部分响应2:

<partial-response>
    <error>
          <error-name>class java.lang.IndexOutOfBoundsException</error-name>
          <error-message>
              <![CDATA[ Index: 0, Size: 0 ]]>
          <error-message>
    </error>
</partial-response>
<partial-response>
   <changes>
       <update id="javax.faces.ViewState">-4640542341950585998:4269573232206322924</update>
   </changes>
</partial-response>

-4640542341950585998:4269573232206322924
我们目前正在使用Omnifaces 2.0FullAjaxExceptionHandlerFactory,我们还在会话管理过滤器中使用banterCz的JSFDirectStrategy进行过期会话重定向

public类JSFDirectStrategy实现InvalidSessionStrategy{
私有记录器Logger=LoggerFactory.getLogger(getClass());
私有静态最终字符串FACES\u REQUEST\u HEADER=“FACES REQUEST”;
私有字符串invalidSessionUrl;
/**
*{@inheritardoc}
*/
@凌驾
检测到公共无效onInvalidSessionDetected(HttpServletRequest请求,HttpServletResponse响应)引发IOException,ServletException{
布尔ajaxRedirect=“partial/ajax”.equals(request.getHeader(FACES\u request\u HEADER));
如果(ajaxRedirect){
字符串contextPath=request.getContextPath();
字符串重定向URL=contextPath+invalidSessionUrl;
debug(“会话因ajax请求而过期,重定向到“{}”,重定向URL);
字符串ajaxRedirectXml=createAjaxRedirectXml(重定向URL);
debug(“对重定向的Ajax部分响应:{}”,ajaxRedirectXml);
setContentType(“text/xml”);
response.getWriter().write(ajaxRedirectXml);
}否则{
String requestURI=getRequestUrl(请求);
debug(“会话因非ajax请求而过期,启动新会话并重定向到请求的url'{}',requestURI”);
request.getSession(true);
sendRedirect(requestURI);
}
}
私有字符串getRequestUrl(HttpServletRequest请求){
StringBuffer requestURL=request.getRequestURL();
字符串queryString=request.getQueryString();
if(StringUtils.hasText(queryString)){
requestURL.append(“?”).append(queryString);
}
返回requestURL.toString();
}
私有字符串createAjaxRedirectXml(字符串重定向URL){
返回新的StringBuilder()
.附加(“”)
.附加(“”)
.toString();
}
public void setInvalidSessionUrl(字符串invalidSessionUrl){
this.invalidSessionUrl=invalidSessionUrl;
}
}
faces config.xml

<factory>
     <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
</factory>
<context-param>
    <param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
    <param-value>1048576</param-value>
</context-param>

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/error/viewexpiredpage.xhtml</location>
</error-page>

<error-page>
    <error-code>404</error-code>
    <location>/error/pagenotfound.xhtml</location>
</error-page>

<error-page>
    <error-code>500</error-code>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>org.springframework.web.client.RestClientException</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>org.springframework.web.client.HttpServerErrorException</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

org.omnifaces.exceptionhandler.fullajaxexceptionhandler工厂
web.xml

<factory>
     <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
</factory>
<context-param>
    <param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
    <param-value>1048576</param-value>
</context-param>

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/error/viewexpiredpage.xhtml</location>
</error-page>

<error-page>
    <error-code>404</error-code>
    <location>/error/pagenotfound.xhtml</location>
</error-page>

<error-page>
    <error-code>500</error-code>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>org.springframework.web.client.RestClientException</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

<error-page>
    <exception-type>org.springframework.web.client.HttpServerErrorException</exception-type>
    <location>/error/globalerrorpage.xhtml</location>
</error-page>

javax.faces.FACELETS\u缓冲区\u大小
1048576
javax.faces.application.ViewExpiredException
/错误/viewexpiredpage.xhtml
404
/错误/pagenotfound.xhtml
500
/错误/globalerrorpage.xhtml
java.lang.Exception
/错误/globalerrorpage.xhtml
org.springframework.web.client.RestClientException
/错误/globalerrorpage.xhtml
org.springframework.web.client.HttpServerErrorException
/错误/globalerrorpage.xhtml

这个问题有两个方面。1) 特定的异常是由一个bug引起的,但是如果没有看到完整的堆栈跟踪(检查服务器日志),就无法回答这个问题。2) 异常处理未正确配置(请告诉您是如何配置的)。感谢您的回复。这个问题似乎是间歇性的,因为我们无法始终如一地复制它。我们目前正在使用Omnifaces 2.0 FullAjaxExceptionHandlerFactory来处理JSF ajax请求期间发生的异常,对于过期会话,我们实现了banterCz的JSFDirectStrategy,以便在会话过期时重定向到无效会话url(登录页面)。你知道是什么导致了这个问题吗?我们目前正在检查Primefaces是否是导致上述问题的原因。没有堆栈跟踪,我无法继续。嗨,BalusC,我再次遇到间歇性IndexOutOfBoundsException。我已经在这里发布了日志,我使用了与您相同的组件(JSFRedirectStrategy、FullAjaxExceptionHandlerFactory),并且遇到了来自的异常。遗憾的是,stacktrace的问题不再可用。你能在哪里修好它?