freemarker

JSP vs FreeMarker [closed]

喜夏-厌秋 提交于 2019-12-20 08:44:33
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Does JSP provide more flexibility then FreeMarker or is it other way around? My back-end involves Servlets. Which one is used under

Difference between ?? , has_content , if_exists in freemarker

久未见 提交于 2019-12-20 08:00:36
问题 what is the difference between the following in freemarker? ! has_content ?? if_exists I used ?? instead of has_content & it lead to such huge issues. Screwed up my day. I really need to get this thing clarified. When I used !(xyz.abc!)?? -- it dint work When I used !(xyz.abc!)?has_content ... it did work Doesn't ?? OR has_content OR if_exists check for the same thing? 回答1: ?? tells if the left hand operand's value is missing (means it's Java null or you have an undefined variable there), and

FreeMarker hello

两盒软妹~` 提交于 2019-12-20 06:48:41
一、什么是 FreeMarker   FreeMarker 是一个用 Java 语言编写的模板引擎,它基于模板来生成文本输出。 FreeMarker 与 Web 容器无关,即在 Web 运行时,它并不知道 Servlet 或 HTTP 。它不仅可以用作表现层的实现技术,而且还可以用于生成 XML , JSP 或 Java 等。 目前企业中 : 主要用 Freemarker 做静态页面或是页面展示 二、在 eclipse 上安装 FreeMarker 插件 1、FreeMarker 插件下载   链接:https://pan.baidu.com/s/12deTWocaiMqvLiZ-TcdqsA 密码:m166 2、把该插件放到 eclipse 指定的目录下,然后重启 eclipse 三、FreeMarker 用法 1、在 WEB-INFO 目录下新建 ftl 目录,在 ftl 目录下新建 hello.flt 文件,该文件就是模板文件。 ( 该文件名的后缀任意,但是 FreeMarker 默认后缀是 ftl ) 2、 hello.flt 文件内容 ${hello} 3、java 测试代码 @Test public void testFreeMarker() throws Exception { //1、创建一个模板文件 //2、创建一个Configuration对象

Freemarker: Dynamic interpolation of sub variables

a 夏天 提交于 2019-12-20 06:12:19
问题 I am trying to create a FreeMarker macro that can return the interpolation of a concatenation of a string and the input variable: <#macro findValue var> <#if (.vars["foo." + var]) ??> .vars["foo." + var] <#else> ${.vars["bar." + var]} </#if> </#macro> Unfortunately it doesn't work. Firstly, ${.vars["bar." + var]} gives an undefined error. Secondly, the if condition always returns false even when I can see that the sub variable do exist. It seems like the .vars variable can only look up root

Disable freemarker logs

左心房为你撑大大i 提交于 2019-12-20 03:33:18
问题 I'm using Struts 2.0.11.2 and I don't what was changed recently in my app that I get TONS of freemarker logs: DEBUG 13201 [freemark] (): template/simple/hidden.ftl[en,UTF-8,parsed] cached copy not yet stale; using cached. How can I turn off these annoying logs? I know of the freemarker.properties file but I don't find how to specify log levels from there. I tried the hack in my code: freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE); and for some people it doesn't

How to convert date in specific format in Freemarker template or javascript

隐身守侯 提交于 2019-12-19 18:24:35
问题 From json, i am getting the value as "createdOn": "Jan 08 2015 20:40:56 GMT+0530 (IST)", I am Accessing in FTL <#list variables as variable> <div class="reply"> ${variable.createdOn} </div> </#list> The result i am getting is Jan 09 2015 12:36:18 GMT+0530 (IST) My preferable format is 09-01-2015 I need to remove rest of the time GMT, IST and so on. How to convert this in Freemarker template or javascript. Update I tried to pass below like this ${variable.createdOn?datetime?string("dd-MM-yyyy"

Java.time (Java 8) support in Freemarker

最后都变了- 提交于 2019-12-19 17:33:04
问题 Does anybody know of any plans to support the new java.time api in FreeMarker? Or has anybody code laying around for supporting classes like ZonedDateTime, LocalDateTime and Instant? Its not hard to see how to implement these things myself, but it is actually a rather big task. 回答1: Let's assume that you want format new date/time objects Create custom method: public static class FormatDateTimeMethodModel implements TemplateMethodModelEx { public Object exec(List args) throws

How do you declare a the “nbsp” entity in XML document

丶灬走出姿态 提交于 2019-12-19 11:42:53
问题 I am getting the following error The entity "nbsp" was referenced, but not declared. I tried to declare the nbsp (shown below) in my XML file. But this isn't working for me. <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" > <!DOCTYPE html [<!ENTITY nbsp " "> Am I missing something? Thanks! 回答1: Put the DOCTYPE declaration before the root element start-tag. That is, <?xml version

How to set content-type in Freemarker views when using Spring MVC?

随声附和 提交于 2019-12-19 06:46:56
问题 I'm using Sping MVC with freemarker views. I set up a FreeMarkerViewResolver to resolve the views and it works so far but now I have encoding problems. All my views are HTML 5 pages in UTF-8 encoding and I also added a <meta charset="UTF-8" /> to the HTML page but characters are still printed in the wrong encoding. I checked the HTTP headers with curl and found this: k@jules:~$ curl -I http://localhost:8080/testweb/test.view HTTP/1.1 200 OK Content-Type: */*;charset=ISO-8859-1 But when I

How to make Netbeans' templates that creates more than 1 file?

浪子不回头ぞ 提交于 2019-12-19 06:46:52
问题 One of the most awesome features of Netbeans is to generate code using some FreeMarker templates. I have some questions about it, I hope someone here can help me. How can I make a template on Netbeans that generates more than just 1 file? For example, I use the "JSF Pages From Entity Beans" wizard to generate CRUD files . So it creates automatically 4 files for each entity I have: - Create.xhtml - Edit.xhtml - List.xhtml - View.xhtml This is very useful, because you often needs to create,