freemarker错误九

freemarker错误九

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

1、错误叙述性说明

五月 30, 2014 11:52:04 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error
严重: Template processing error: "Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-in with this date."

Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?

date, ?time or ?datetime built-in, or ?

string.<format> or ?string(format) built-in with this date.The problematic instruction:----------==> ${nowsday} [on line 23, column 6 in type.ftl]----------Java backtrace for programmers:----------freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?

time or ?datetime built-in, or ?string.<format> or ?string(format) built-in with this date. at freemarker.core.Environment.formatDate(Environment.java:776) at freemarker.core.Expression.getStringValue(Expression.java:105) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 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:173) at com.you.test.freemarker.FreemarkerTest.testDataType(FreemarkerTest.java:160) 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> 张三丰 123,456 true false Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?

date, ?

time or ?

datetime built-in, or ?

string.<format> or ?string(format) built-in with this date.The problematic instruction:----------==> ${nowsday} [on line 23, column 6 in type.ftl]----------Java backtrace for programmers:----------freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?

date, ?

time or ?datetime built-in, or ?string.<format> or ?string(format) built-in with this date. at freemarker.core.Environment.formatDate(Environment.java:776) at freemarker.core.Expression.getStringValue(Expression.java:105) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 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:173) at com.you.test.freemarker.FreemarkerTest.testDataType(FreemarkerTest.java:160) 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)Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?

time or ?datetime built-in, or ?string.<format> or ?string(format) built-in with this date.The problematic instruction:----------==> ${nowsday} [on line 23, column 6 in type.ftl]----------Java backtrace for programmers:----------freemarker.template.TemplateModelException: Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?

date, ?time or ?

datetime built-in, or ?string.<format> or ?string(format) built-in with this date. at freemarker.core.Environment.formatDate(Environment.java:776) at freemarker.core.Expression.getStringValue(Expression.java:105) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) 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:173) at com.you.test.freemarker.FreemarkerTest.testDataType(FreemarkerTest.java:160) 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基本数据类型
	 * @Title:testDataType
	 * @Description:
	 * @param:
	 * @return: void
	 * @throws
	 */
	@Test
	public void testDataType()
	{
		root.put("nowsday", new Date());
		studentPrint("type.ftl");
	}

${nowsday}


     不能将日期类型直接转换为字符串。由于不知道是日期类型中的哪一种在使用。是date、time还是datetime。而且不知道转换成字符串日期究竟显示成什么格式,是yyyy-MM-dd。还是HH:mm:ss,还是yyyy-MM-dd HH:mm:ss


3、解决的方法

 <#--日期类型-->
${nowsday?string("yyyy-MM-dd")}


结果:2014-05-31

版权声明:本文博客原创文章,博客,未经同意,不得转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/117586.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • oracle split 分割字符串,Oracle字符串分割Split[通俗易懂]

    oracle split 分割字符串,Oracle字符串分割Split[通俗易懂]Oracle字符串分割Split一、创建数组类型Sql代码CREATEORREPLACETYPET_RET_TABLEISTABLEOFVARCHAR2(512)二、创建字符串分割函数Sql代码CREATEORREPLACEFUNCTIONF_SPLIT_STRING(AS_STRVARCHAR2,AS_SPLITVARCHAR2)RETURNT_RET_TABL…

  • python动态心形代码简单_python心形曲线代码

    python动态心形代码简单_python心形曲线代码欢迎关注【拇指笔记】,持续更新一些好玩、有趣的Python小项目。需要程序的朋友,直接私信我即可。原文链接【Python】五分钟画一条动态心形曲线~​mp.weixin.qq.com先上效果使用Python绘制一条动态的心形曲https://www.zhihu.com/video/12280010884537671681.绘制一条心形曲线最近看到个视频,打算绘制个心型动态的曲线。1.1Matla…

    2022年10月16日
  • ping traceroute原理

    ping traceroute原理ping命令工作原理ping命令主要是用于检测网络的连通性。Ping命令发送一个ICMP请求报文给目的IP,然后目的IP回复一个ICMP报文。原理:网络上的机器都有唯一确定的IP地址,我们给目标IP地址发送一个数据包,对方就要返回一个同样大小的数据包,根据返回的数据包我们可以确定目标主机的存在,可以初步判断目标主机的操作系统等。因为ping命令是使用ICMP协议,…

  • 赚一个亿真的不难,不信你看下面代码

    赚一个亿真的不难,不信你看下面代码privatevoidComputeActionPerformed(java.awt.event.ActionEventevt){//TODOaddyourhandlingcodehere:if(Salary.getText().isEmpty()||Aim.getText().isEmpty()||Saving.getText().isEmpty()){..

  • 《算法设计与分析》期末不挂科的原因_算法设计与分析重点

    《算法设计与分析》期末不挂科的原因_算法设计与分析重点考前知识点整理算法分析基础算法的定义算法正确性算法的性质程序的定义程序与算法的区别算法设计和分析的步骤复杂度分析算法的时间复杂性算法渐近复杂性渐近分析的记号渐近上界记号渐近下界记号非紧上界记号非紧下界记号紧渐近界记号意义算法分析中常见的复杂性函数我们学校开设的这门课,过于理论,实践太少,考试不会太难,一起学习,一起不挂科!但是算法平时一定要练哦!加油!算法分析基础算法的定义算法是指解决问题的一种方法或一个过程。算法是若干指令的有穷序列。算法正确性对每一个输入实例算法都能终止,并给出

  • 23种设计模式(5):原型模式

    23种设计模式(5):原型模式

    2021年12月10日

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号