(1) Exception in thread "main" org.apache.velocity.exception.ParseErrorException: Encountered " }</td>\r\n
<td>" at velocity/list.jsp[line 41, column 17]
Was expecting one of:
"}" ...
<DOT> ...
at org.apache.velocity.Template.process(Template.java:141)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource
(ResourceManagerImpl.java:446)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource
(ResourceManagerImpl.java:354)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:326)
at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:404)
at cn.cong.pss.test.VelocityTest.main(VelocityTest.java:45)
在运行时,出现这个错误是因为在写JSP时,在这个标签中多了一个空格:<td>${name }</td> 解释不了"}" 而导致的错误,把空格去掉就可以了
(2)Exception in thread "main" org.apache.velocity.exception.ParseErrorException: Encountered "+1})\">\u4e0b\u4e00\u9875 </a></td>\r\n <td><a class=\"sye\" href=\"" at velocity/employee.jsp[line 81, column 58]
Was expecting one of:
"}" ...
<DOT> ...
"(" ...
at org.apache.velocity.Template.process(Template.java:141)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:446)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:326)
at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:404)
at cn.cong.pss.test.VelocityTest.main(VelocityTest.java:45)
出现这个错误 的原因是因为在模版中的jsp页面里,使用了一个加法运算 <td><a class="sye" href="#" οnclick="go(${page.pageNo+1})">下一页 </a></td>
而在velocity里,它把 page.pageNo当作一个变量,不是允许作加法运算的。所以就出现错误。 正确 的做法可以这样:将有作运算的的部分代码分离出来。我
这里的是分页,所以我把分页这部分的代码分离出来,然后通过<%@include file=""%>,将其引用出来