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的方法中通 ...
随机推荐
- c# 实现mysql事务
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- python threading queue模块中join setDaemon及task_done的使用方法及示例
threading: t.setDaemon(True) 将线程设置成守护线程,主进行结束后,此线程也会被强制结束.如果线程没有设置此值,则主线程执行完毕后还会等待此线程执行. t. ...
- JDBC(二)
三层架构的一些基本报结构如下: domain包:下面是一些实体bean,属性为private,提供属性相对应的set和get方法.一般对应于数据库中的一张数据表,属性对应于数据表中的列. dao包,数 ...
- IntelliJ IDEA使用心得之插件篇
今天和大家分享下插件的安装方法,顺便推荐几个非常好用的插件. 1.安装插件 在工具栏中,点击进入IDE设置界面. 插件仓库界面: 值得注意的是,每次安装/卸载插件后,需要重启IDE. 2.好用的插件 ...
- DNA序列局部比对(Smith–Waterman algorithm)
生物信息原理作业第三弹:DNA序列局部比对,利用Smith–Waterman算法,python3.6代码实现. 实例以及原理均来自https://en.wikipedia.org/wiki/Smith ...
- SDN第二次上机作业
作业链接 安装floodlight 生成拓扑并连接控制器floodlight,利用控制器floodlight查看图形拓扑 from mininet.topo import Topo class MyT ...
- python中的randint,引入模块
引入模块的方法: from 模块名 import 方法名 范例: from random import randint#使用randint需要加上这句 while True: answer=randi ...
- python装饰器探究与参数的领取
首先上原文, 现在,假设我们要增强now()函数的功能,比如,在函数调用前后自动打印日志,但又不希望修改now()函数的定义,这种在代码运行期间动态增加功能的方式,称之为"装饰器" ...
- 如何在Centos 7上用Logrotate管理日志文件
何为Logrotate? Logrotate是一个实用的日志管理工具,旨在简化对系统上生成大量的日志文件进行管理. Logrotate允许自动旋转压缩,删除和邮寄日志文件,从而节省宝贵的磁盘空间. L ...
- CentOS7上安装并配置Nginx、PHP、MySql
一.Nginx 1.安装nginx yum install nginx 2.启动nginx systemctl start nginx 除了systemctl start nginx之外,常用的相关命 ...