提交响应后无法创建会话....为什么? [英] Cannot create a session after the response has been committed....Why?

查看:566
本文介绍了提交响应后无法创建会话....为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version='1.0' encoding='UTF-8' ?>

小面标题

Facelet Title

            <f:facet name="header">Books And Authors....</f:facet>
            <h:panelGrid columns="2" rules="cols">



                <h:panelGrid id="pan1" columns="2">

                    <h:outputText value="Select Author"/>
                    <p:selectOneMenu value="#{bean.selectedAuthor}" converter="authorConverter">

                        <f:selectItems value="#{bean.authors}" var="author"
                                       itemLabel="#{author.name}" itemValue="#{author}"/>
                    </p:selectOneMenu>
                    <h:outputText value="Select Books"/>
                    <p:selectManyMenu value="#{bean.selectedBook}" converter="bookConverter">
                        <f:selectItems value="#{bean.books}" var="books"
                                       itemLabel="#{books.name}" itemValue="#{books}"/>
                    </p:selectManyMenu>
                    <p:commandButton value="Add" process="@form:pan1" update="@form:pan1" action="#{bean.add}" />
                </h:panelGrid>

                <h:panelGrid id="pan2" columns="2">
                    <h:outputText value="Enter Book name:"/>
                    <p:inputText value="#{bean.name}"/>

                    <p:commandButton value="Search" process="@form:pan2" update="@form:pan2" action="#{bean.search}"/>
                    <p:commandButton value="Inner Join" process="@form:pan2" update="@form:pan2" action="#{bean.innerJoin}"/>
                    <p:commandButton value="Outer Join" process="@form:pan2" update="@form:pan2" action="#{bean.outerJoin}"/>
                    <p:commandButton value="Fetch Join" process="@form:pan2" update="@form:pan2" action="#{bean.fetchJoin}"/>
                    <p:dataTable value="#{bean.results}" var="authors">

                        <p:column>
                            <f:facet name="header">Author Name</f:facet>
                            #{authors.name}
                        </p:column>
                        <p:column>
                            <f:facet name="header">Book Name</f:facet>
                            <p:dataTable value="#{authors.books}" var="book">
                                <p:column>
                                  #{book.name}
                                </p:column>
                            </p:dataTable>
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>

            </h:panelGrid>
        </p:panel>
    </h:form>
</h:body>

警告:JSF1087:由于已经提交了响应,因此无法生成Facelets错误页面. 严重:javax.faces.FacesException:PWC3999:提交响应后无法创建会话

WARNING: JSF1087: Unable to generate Facelets error page as the response has already been committed. SEVERE: javax.faces.FacesException: PWC3999: Cannot create a session after the response has been committed

我该如何解决?

推荐答案

要创建会话,您(几乎总是)需要设置一个会话cookie.当响应已经提交(即HTTP标头已经发送到客户端)时,这是不可能的.在这种情况下,Facelets似乎在内部需要进行会话才能完成某些事情.

In order to create a session, you (almost always) need to set a Session cookie. That is not possible when the response has already been committed (i.e. the HTTP headers already sent to the client). In this case, it seems that Facelets internally needs a session for something.

我该如何解决?

how can i solve this?

在您的代码的前面创建一个会话.您不必输入任何会话属性,只需确保存在一个会话即可.

Create a session earlier in your code. You don't have to put in any session attributes, just make sure that a session exists.

这篇关于提交响应后无法创建会话....为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆