@闲.大赋 你好,想跟你请教个问题版本beetl-core-2.0.13.jar:
原来写了自定义迭代标签,需要需要获取迭代的索引值,所有我在变量的里面添加一个bind方法绑定索引值。下面是自定义标签的源代码,
this.bind("zzzz",i);
上面就是绑定索引值的代码
/** * 用于遍历多个系统参数 * @author Administrator * */ @BeetlName("param") public class ParamTag extends BaseTag { public void render() { String key = String.valueOf(this.getAttributeValue("type")); if(key!=null){ List<SysParam> sysParams = KgCacheKit.getSysParamsByType(key); for (int i = 0; i < sysParams.size(); i++) { this.bind(this.args[2].toString(),sysParams.get(i)); this.bind("zzzz",i); this.doBodyRender(); } } } }
this.bind("zzzz",i);
这行报错
下面是错误信息
2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - >>错误:htmltagvar 位于68行 资源:/public/user/template/set_sign.html 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - tag执行抛错 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 65| <div class="form-group"> 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 66| <label class="col-md-2 control-label required">指定页码</label> 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 67| <div class="col-md-8"> 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 68| <#param type="sign.page" ; target> 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 69| <label class='radio-inline'><input type="radio" name="page" value="${target.code}" ${zzzz ==0?'checked'}> ${target.name} </label> 2014-11-25 18:08:02 625 [http-8089-5] [ERROR] - 70| </#param> java.lang.RuntimeException at org.beetl.core.GeneralVarTagBinding.bind(GeneralVarTagBinding.java:105) at com.kg.core.beetl.tag.ParamTag.render(ParamTag.java:28) at org.beetl.ext.tag.HTMLTagVarBindingWrapper.render(HTMLTagVarBindingWrapper.java:47) at org.beetl.core.statement.TagVarBindingStatement.runTag(TagVarBindingStatement.java:54) at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87) at org.beetl.core.statement.Program.execute(Program.java:70) at org.beetl.core.engine.FastRuntimeEngine$FilterProgram.execute(FastRuntimeEngine.java:43) at org.beetl.core.Template.renderTo(Template.java:121) at org.beetl.core.Template.renderTo(Template.java:87) at com.jfinal.ext.beetl.MyWebRender.render(MyWebRender.java:64) at com.jfinal.ext.beetl.KgWebBeetlRender.render(KgWebBeetlRender.java:27) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) 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:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) 2014-11-25 18:08:02 640 [http-8089-5] [ERROR] - /user/template/set_sign/1-20?q_templateid=ce0f209f9c714ead86e3945e718eb132 com.jfinal.render.RenderException: ERROR at com.jfinal.ext.beetl.KgWebBeetlRender.render(KgWebBeetlRender.java:31) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92) at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72) 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:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) Caused by: ERROR at org.beetl.core.statement.TagVarBindingStatement.runTag(TagVarBindingStatement.java:63) at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87) at org.beetl.core.statement.Program.execute(Program.java:70) at org.beetl.core.engine.FastRuntimeEngine$FilterProgram.execute(FastRuntimeEngine.java:43) at org.beetl.core.Template.renderTo(Template.java:121) at org.beetl.core.Template.renderTo(Template.java:87) at com.jfinal.ext.beetl.MyWebRender.render(MyWebRender.java:64) at com.jfinal.ext.beetl.KgWebBeetlRender.render(KgWebBeetlRender.java:27) ... 14 more Caused by: java.lang.RuntimeException at org.beetl.core.GeneralVarTagBinding.bind(GeneralVarTagBinding.java:105) at com.kg.core.beetl.tag.ParamTag.render(ParamTag.java:28) at org.beetl.ext.tag.HTMLTagVarBindingWrapper.render(HTMLTagVarBindingWrapper.java:47) at org.beetl.core.statement.TagVarBindingStatement.runTag(TagVarBindingStatement.java:54) ... 21 more
页面的html代码如下
<#param type="sign.page" ; target> <label class='radio-inline'><input type="radio" name="page" value="${target.code}" ${zzzz ==0?'checked'}> ${target.name} </label> </#param>
在标签里:
具体可以参考文档: http://ibeetl.com/guide/ 2.22.绑定变量的HTML标签
补充:既可以按照名字绑定,也可以按照顺序绑定(这是推荐的方式),
你那个报错是因为代码里绑定了多个变量,但实际只申明了一个。错误提示不是很清楚,2.1.2版本即将改善此错误提示:比如
补充:既可以按照名字绑定,也可以按照顺序绑定(这是推荐的方式),
你那个报错是因为代码里绑定了多个变量,但实际只申明了一个。错误提示不是很清楚,2.1.2版本即将改善此错误提示:比如
补充:既可以按照名字绑定,也可以按照顺序绑定(这是推荐的方式),
你那个报错是因为代码里绑定了多个变量,但实际只申明了一个。错误提示不是很清楚,2.1.2版本即将改善此错误提示:比如
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。