freemarker自定义标签报错(四)
freemarker自定义标签
1、错误描述
六月 05, 2014 11:31:35 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template processing error: "Error executing macro: write\nrequired parameter: nums is not specified." Error executing macro: write required parameter: nums is not specified. The problematic instruction: ---------- ==> macro write [on line 11, column 10 in myself.ftl] in user-directive write [on line 18, column 10 in myself.ftl] ---------- Java backtrace for programmers: ---------- freemarker.template.TemplateException: Error executing macro: write required parameter: nums is not specified. at freemarker.core.Macro$Context.sanityCheck(Macro.java:211) at freemarker.core.Macro$Context.runMacro(Macro.java:169) at freemarker.core.Environment.visit(Environment.java:614) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:217) at com.you.test.freemarker.FreemarkerTest.testMyself(FreemarkerTest.java:204) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>freemarker自定义标签</title> </head> <body> Error executing macro: write required parameter: nums is not specified. The problematic instruction: ---------- ==> macro write [on line 11, column 10 in myself.ftl] in user-directive write [on line 18, column 10 in myself.ftl] ---------- Java backtrace for programmers: ---------- freemarker.template.TemplateException: Error executing macro: write required parameter: nums is not specified. at freemarker.core.Macro$Context.sanityCheck(Macro.java:211) at freemarker.core.Macro$Context.runMacro(Macro.java:169) at freemarker.core.Environment.visit(Environment.java:614) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:217) at com.you.test.freemarker.FreemarkerTest.testMyself(FreemarkerTest.java:204) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Error executing macro: write required parameter: nums is not specified. The problematic instruction: ---------- ==> macro write [on line 11, column 10 in myself.ftl] in user-directive write [on line 18, column 10 in myself.ftl] ---------- Java backtrace for programmers: ---------- freemarker.template.TemplateException: Error executing macro: write required parameter: nums is not specified. at freemarker.core.Macro$Context.sanityCheck(Macro.java:211) at freemarker.core.Macro$Context.runMacro(Macro.java:169) at freemarker.core.Environment.visit(Environment.java:614) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:221) at freemarker.core.Environment.process(Environment.java:199) at freemarker.template.Template.process(Template.java:259) at com.you.freemarker.FreemarkerTemplate.printFtl(FreemarkerTemplate.java:77) at com.you.test.freemarker.FreemarkerTest.studentPrint(FreemarkerTest.java:217) at com.you.test.freemarker.FreemarkerTest.testMyself(FreemarkerTest.java:204) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
2、错误原因
<#--freemarker自定义标签--> <#--对于write自定义标签有两个参数,nums是次数,name是名称--> <#macro write nums name> <#list 1..nums as num> 姓名:张三丰 性别:男 </#list> </#macro> <@write/>
由于write自定义标签有两个参数,在调用它的时候需要给两个参数指定值,否则报错
3、解决办法
<@write nums=4 name="你好!"/>
给两个参数赋值
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>freemarker自定义标签</title> </head> <body> <#--freemarker自定义标签--> <#--对于write自定义标签有两个参数,nums是次数,name是名称--> <#macro write nums name> <#list 1..nums as num> 姓名:张三丰 性别:男 </#list> </#macro> <@write nums=4 name="你好!"/> </body> </html>
运行结果:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>freemarker自定义标签</title> </head> <body> 姓名:张三丰 性别:男 姓名:张三丰 性别:男 姓名:张三丰 性别:男 姓名:张三丰 性别:男 </body> </html>
freemarker自定义标签报错(四)的更多相关文章
- freemarker自定义标签报错(六)
freemarker自定义标签 1.错误描述 freemarker.core.ParseException: Encountered "\"\u4f60\u597d\uff01\& ...
- freemarker自定义标签报错(五)
freemarker自定义标签 1.错误描述 六月 05, 2014 11:40:49 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严 ...
- freemarker自定义标签报错(三)
freemarker自定义标签 1.错误描述 freemarker.core.ParseException: Encountered " " at line 14, column ...
- freemarker自定义标签报错(二)
freemarker自定义标签 1.错误描述 freemarker.core.ParseException: Unexpected end of file reached. at freemarker ...
- freemarker自定义标签报错(一)
freemarker自定义标签 1.错误描述 freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgr ...
- freemarker自定义标签报错(七)
1.错误描述 六月 09, 2014 11:11:09 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template proc ...
- freemarker自定义标签报错(八)
1.错误描述 freemarker.core.ParseException: Token manager error: freemarker.core.TokenMgrError: Unknown d ...
- 如何自定义JSTL标签与SpringMVC 标签的属性中套JSTL标签报错的解决方法
如何自定义JSTL标签 1.创建一个类,从SimpleTagSupport继承 A) 通过继承可以获得当前JSP页面上的对象,如JspContext I) 实际上可以强转为PageContext II ...
- OneBlog开源博客-详细介绍如何实现freemarker自定义标签
前言 OneBlog中使用到了springboot + freemarker的技术,同时项目里多个controller中都需要查询一个公有的数据集合,一般做法是直接在每个controller的方法中通 ...
随机推荐
- python监控接口请求
#!/usr/bin/env python #coding=utf8 import time,os,sched,urllib,httplib import smtplib import string ...
- SPOJ DIVCNT2 [我也不知道是什么分类了反正是数论]
SPOJ DIVCNT2 - Counting Divisors (square) 题意:求 \[ \sum_{i=1}^n\sigma_0(i^2) \] 好棒啊! 带着平方没法做,考虑用其他函数表 ...
- 网络服务器操作命令telnet
有些命令是内部的,系统自带的,在装好系统后,就可以随时使用有些命令是系统中没有的,要自己安装一下才能使用,比如你说的telnet,需要安装一下才能使用的.CentOS中用 yum install te ...
- Redis 学习(三) —— 事务、消息发布订阅
一.Redis事务 Redis 提供的事务机制与传统的数据库事务有些不同,传统数据库事务必须维护以下特性:原子性(Atomicity), 一致性(Consistency),隔离性(Isolation) ...
- FastStone Capture的使用
FastStone Capture的使用 FastStone Capture是一款精简而优秀的图像处理软件,在工作中会经常用到.我在本地安装了FastStone Capture 8.4版本 (提取码: ...
- jq模仿雨滴下落的动画
效果如图: 实现思路:定时器每隔x秒生成宽高.下落速度(即动画执行时间).left随机的div. 1.CSS: body{ overflow: hidden;/*这是为了防止出现滚动条*/ } .co ...
- 移动web页面给用户发送邮件的方法
微信商户通有这么一个需求,用户打开H5页面后,引导用户到电脑下载设计资源包,由于各种内部原因,被告知无后台资源支持,自己折腾了一段时间找了下面2个办法,简单做下笔记. 使用mailto功能,让用户自己 ...
- Netbeans文件被误删怎么办?
辛辛苦苦写的代码突然不见了,上午还是有的,哪去了?怎么办? 破解办法: 1,良好的版本管理工具(git||svn)使用习惯,代码每天上传更新,技术文件有丢失,也就一天的. 2,Netbeans提供的备 ...
- 微博爬虫“免登录”技巧详解及 Java 实现(业余草的博客)
一.微博一定要登录才能抓取? 目前,对于微博的爬虫,大部分是基于模拟微博账号登录的方式实现的,这种方式如果真的运营起来,实际上是一件非常头疼痛苦的事,你可能每天都过得提心吊胆,生怕新浪爸爸把你的那些账 ...
- 阿里巴巴分布式服务框架 Dubbo 介绍
Dubbo是阿里巴巴内部的SOA服务化治理方案的核心框架,每天为2000+ 个服务提供3,000,000,000+ 次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点.Dubbo自2011年开源后, ...