FreeMarker template error!

部署项目后发现以下“FreeMarker template error!”的问题,google、baidu猛一顿搜索无果后开始认真分析异常信息。

FreeMarker template error!
Error on line 72, column 6 in template/ajax/head.ftl
Expecting a boolean (true/false) expression here
Expression parameters.debug?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
The problematic instruction:
----------
==> if parameters.debug?default(false) [on line 72, column 1 in template/ajax/head.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.NonBooleanException: Error on line 72, column 6 in template/ajax/head.ftl
Expecting a boolean (true/false) expression here
Expression parameters.debug?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
	at freemarker.core.Expression.isTrue(Expression.java:150)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
	at freemarker.core.Environment.visit(Environment.java:196)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:196)
	at freemarker.core.Environment.process(Environment.java:176)
	at freemarker.template.Template.process(Template.java:232)
	at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168)
	at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530)
	at org.apache.struts2.components.UIBean.end(UIBean.java:484)
	at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
	at org.apache.jsp.WebUI.UserCenter.modifyUserInfo_jsp._jspx_meth_sd_005fhead_005f0(modifyUserInfo_jsp.java:389)
	at org.apache.jsp.WebUI.UserCenter.modifyUserInfo_jsp._jspService(modifyUserInfo_jsp.java:99)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)

一句异常都没有看懂,但是发现和项目有关的两条异常,如下:

      at org.apache.jsp.WebUI.UserCenter.modifyUserInfo_jsp._jspx_meth_sd_005fhead_005f0(modifyUserInfo_jsp.java:389)
	at org.apache.jsp.WebUI.UserCenter.modifyUserInfo_jsp._jspService(modifyUserInfo_jsp.java:99)

打开tomcat部署的modifyUserInfo_jsp.java文件,定位到99行。

 96       out.write("<!DOCTYPE html >\n");
 97       out.write("<html>\n");
 98       out.write("<head>\n");
 99       if (_jspx_meth_sd_005fhead_005f0(_jspx_page_context))
100         return;
101       out.write("\n");
102       out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
和源代码进行对比
 13 <!DOCTYPE html >
 14 <html>
 15 <head>
 16 <sd:head/>
 17 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
询问相关开发人员后,发现源代码16行为多余代码,删除后异常消除,没有再深入研究389行代码。

总结:遇到不认识、没见过的异常信息,不用害怕,认真分析,或许就是一个简单的语法错误。

posted @ 2013-08-08 15:51  penzz  阅读(10861)  评论(0编辑  收藏  举报