严重: Servlet.service() for servlet [default] in context with path [/whiteStruts2] threw exception

java.lang.IllegalStateException: Cannot call sendError() after the response has been committed

at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:462)

at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:770)

at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:505)

at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

......等以下我就不复制粘贴了


网页有如下异常:FreeMarker template error!

Expression title is undefined on line 4, column 18 in test.ftl.
The problematic instruction:
----------
==> ${title} [on line 4, column 16 in test.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression title is undefined on line 4, column 18 in test.ftl.
	at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
	at freemarker.core.Expression.getStringValue(Expression.java:118)
	at freemarker.core.Expression.getStringValue(Expression.java:93)
	at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Environment.process(Environment.java:188)
	at freemarker.template.Template.process(Template.java:237)
	at org.apache.struts2.views.freemarker.FreemarkerResult.doExecute(FreemarkerResult.java:187)
	at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
	at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

解决方法:在freemarker的应用中,出现如上错误是因为,你的ftl模板中的某一个(比如:${name}),其中name并没有放入Map中或者不存在这样的key.