提交响应后无法创建会话......为什么?

发布于 2024-12-20 03:59:59 字数 3047 浏览 1 评论 0原文

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

小面标题

            <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:提交响应后无法创建会话

我该如何解决此问题?

<?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>

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

how can i solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2024-12-27 03:59:59

为了创建会话,您(几乎总是)需要设置会话 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文