浏览 2354 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2004-05-19
index.vm中的相关代码:
[code:1] ……………… <FORM NAME="post" METHOD=POST ACTION="addpost.action"> #tag( Label "label=label test" "name='label name'" "value=scalar" ) <INPUT TYPE="submit" value="提交" > </FORM> ……………… [/code:1] 出错信息如下: [code:1] VelocityServlet: Error processing the template Invalid arg #0 in directive #tag at line 9, column 1 in template /index.vmorg.apache.velocity.exception.ParseErrorException: Invalid arg #0 in directive #tag at line 9, column 1 in template /index.vm at org.apache.velocity.Template.process(Template.java:141) at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:423) at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:341) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:831) at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:303) at org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.java:591) at com.opensymphony.webwork.views.velocity.WebWorkVelocityServlet.handleRequest(WebWorkVelocityServlet.java:72) at org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:358) at org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:317) at javax.servlet.http.HttpServlet.service(HttpServlet.java:126) at javax.servlet.http.HttpServlet.service(HttpServlet.java:103) at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246) at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:164) at com.caucho.server.TcpConnection.run(TcpConnection.java:139) at java.lang.Thread.run(Thread.java:534) [/code:1] 其中,第9行是指 [code:1] #tag( Label "label=label test" "name='label name'" "value=scalar" ) [/code:1] 请问可能是哪儿的问题,没有修改过template 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2004-05-20
macro不是这么用的
假设定义一个macro [code:1]#macro(mytag $name $value) Name: $name Value: $value #end[/code:1] 使用的时候应该是类似: [code:1]#mytag ("myname" "myvalue")[/code:1] 解析出来就是: [code:1]Name: myname Value: myvalue[/code:1] 回到你的问题, [code:1]#tag( Label "label=label test" "name='label name'" "value=scalar" ) [/code:1] 你的第一个参数不是一个合法的变量(例如$xxx),也不是一个合法的值(比如34,"aaa"),报错是应该的,你应该去找找你的macro的定义,我想估摸着你把tag拿掉把Label拿出来估计就好了 |
|
| 返回顶楼 | |
|
最后更新时间:2004-05-20
我用的是velocity1.4,好象在1.4中对这种写法有了新的规定,这种写法在1.4中是非法的,细节还在求证中。
|
|
| 返回顶楼 | |
|
最后更新时间:2004-05-20
我是在webwork2环境下用,我是想用webwork2.jar下面的 /template/xhtml/text.vm,刚才的那个#tag(Label "name=xxxx" "value=xxx")的写法,我是照webwork2的参考来的
|
|
| 返回顶楼 | |
|
最后更新时间:2004-05-20
webwork2.0 xwork1.0+velocity-dep-1.4-是有冲突。
见http://janyou.blogdriver.com/index.jsp 解决的方法之一是修改velocity 1.4的源码 [code:1]class: org.apache.velocity.runtime.parser.Parser method: final public SimpleNode Directive() throws ParseException { ………… argType = DirectiveArg(); if (argType == ParserTreeConstants.JJTWORD) { if (doItNow && argPos == 0) { /* if a VM and it's the 0th arg... ok */ ; } else if( t.image.equals("#foreach") && argPos == 1) { /* if a foreach and it's the 2nd arg ok */ ; } //added by janyou--> else if( t.image.equals("#tag") ) { } else if( t.image.equals("#bodytag") ) { } else if( t.image.equals("#param") ) { } //<--added by janyou else { …………[/code:1] |
|
| 返回顶楼 | |



