org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 1

最近在做Highcharts的过程中,在写js时,出现了以下异常:

 

严重: Servlet.service() for servlet jsp threw exception

org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 10.

Was expecting one of:

    "}" ...

    "." ...

    "[" ...

    ">" ...

    "gt" ...

    "<" ...

    "lt" ...

    ">=" ...

    "ge" ...

    "<=" ...

    "le" ...

    "==" ...

    "eq" ...

    "!=" ...

    "ne" ...

    "&&" ...

    "and" ...

    "||" ...

    "or" ...

    "*" ...

    "+" ...

    "-" ...

    "/" ...

    "div" ...

    "%" ...

    "mod" ...

    

at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2142)

at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2024)

at org.apache.el.parser.ELParser.DynamicExpression(ELParser.java:147)

at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:43)

at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:114)

at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:172)

at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:216)

at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)

at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:937)

at org.apache.jsp.page.M5.M5006_jsp._jspService(M5006_jsp.java:514)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

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

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

at com.kayak.web.user.filter.LoginCertifyFilter.doFilter(LoginCertifyFilter.java:123)

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

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

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

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

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

at com.kayak.web.base.filter.LocalRequestFilter.doFilter(LocalRequestFilter.java:27)

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

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

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

at java.lang.Thread.run(Thread.java:745)

 

这是加载页面时报的错,按异常来看,应该跟el表达式脱不了干系。而注意到由该jsp页面生成的servlet类里报的错误行数(如红色部分所示)。在tomcat中打开该行,发现:

 

out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${point.y:,.0f}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));

 会发现,跟$符号有关!其实,本意是在页面上直接显示$符号,表示美元符号,而并不想赋予它el表达式的含义。——这也是为啥我单独把该页面抽出来,不放在web环境,也就没经过tomcat。页面能正常显示的原因。

 

解决办法:加上转义符:

pointFormat: '<span style="color:{series.color}">{series.name}: <b>\${point.y:,.0f}</b><br>'

 其中\$即把$当成单纯的美元符使用。如果不转义,el的$根本无法解析point.y:,.0f !!

 

-------------------------------------------------------------------------------

附:

1.为了不让charts显示导出的menu

exporting: {
	 	    	   buttons:{
	 	    		   contextButton:{
	 	    			   enabled:false
	 	    		   }
	 	    	   }
	   }

 如果直接这样写:exporting : null 则会报错:can not read property 'buttons' of null(可通过查阅highcharts的API,其中有exporting 属性,即可知道原因。)

 

2.Uncaught Highcharts error #14: www.highcharts.com/errors/14

造成这个原因一般都是Highcharts的series里格式错误或者addPoint操作时格式错误,有时候你的数据来源是由后台加载,就必须注意通过aJax返回到前台的数据,必须是number(int float double等)的数据,而不是String.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值