23 java tomcat struts2 netbeans-7
我在应用程序中执行某些操作时得到了
java.lang.IllegalStateException无法调用sendError()
当我再次重新加载页面时,它会正常工作一段时间,但经过一段时间再次显示相同的异常.我怎样才能克服这个例外?
以下是例外情况:
HTTP Status 500 - Cannot call sendError() after the response has been committed
type Exception report
message Cannot call sendError() after the response has been committed
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException: Cannot call sendError() after the response has been committed
org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:451)
org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:725)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.40 logs.
Run Code Online (Sandbox Code Playgroud)
在struts.xml
<struts>
<package name="default" extends="hibernate-default">
<action name="addUser" method="add" class="com.demo.action.UserAction">
<result name="input">/register.jsp</result>
<result name="success" type="redirect">list</result>
</action>
<action name="list" method="list" class="com.demo.action.UserAction">
<interceptor-ref name="basicStackHibernate" />
<result name="success">/list.jsp</result>
</action>
</package>
</struts>
Run Code Online (Sandbox Code Playgroud)
Bar*_*ett 26
此错误是其他一些问题的症状,而不是您正在寻找的根本原因.
此错误解释了无法将用户重定向到错误页面的原因.(原因:服务器已经将部分响应缓冲区刷回客户端 - 切换/重定向到错误页面为时已晚.)
正如错误消息所指出的那样,检查Apache Tomcat 7日志中的其他位置(或以其他方式调试应用程序)以查找引发异常的内容.
小智 6
对于其他处于我这种情况的人来说——发生的事情是我有两个具有多对多关系的 @Entity 对象,导致生成无限的 json,导致 spring security 抛出此错误。尝试在休眠关系之上添加@JsonIgnore。
您可以尝试这个注释,它会有所帮助,因为它解决了我的问题。
如果它不能帮助您,那么它肯定会有所帮助,然后尝试根据您的要求进行修改。
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
@JsonIdentityReference(alwaysAsId=true)
Run Code Online (Sandbox Code Playgroud)
我正在创建一个@ManyToOne和@OneToMany关系。我在@ManyToOne上方添加了@JsonIgnore,它解决了该错误。
小智 5
注意:您可以导入 2 个@JsonIgnore依赖项。确保它来自杰克逊图书馆;这对我来说很重要:
import com.fasterxml.jackson.annotation.JsonIgnore;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54567 次 |
| 最近记录: |