提交响应后无法创建会话......为什么?
<?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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了创建会话,您(几乎总是)需要设置会话 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.
Create a session earlier in your code. You don't have to put in any session attributes, just make sure that a session exists.