freemarker

Freemarker compress single_line without spaces

被刻印的时光 ゝ 提交于 2021-02-18 06:50:31
问题 It seems that <@compress single_line=true> is replacing line breaks with single spaces (" "), instead of just suppressing them. Example: <@compress single_line=true> "First cell" <#if something > |"Second cell" </#if> |"Third cell" </@compress> Is printing: "First cell" |"Second cell" |"Third cell" Which can't be parsed by a legacy system just because of the spaces between the pipes. Is there any way to avoid this?, perhaps a way to read every "nested" line in a macro to substitute the

freemarker学习 (servlet + freemarker -> Struts2+freemarker -> springMVC+freemarker)

£可爱£侵袭症+ 提交于 2021-02-17 12:30:02
什么是freemarker?   freemarker类似于jsp,但不是jsp!怎么说呢?freemarker文件后缀是.ftl,它不像jsp本质是servlet,它将构建模板、解析模板、使用模板分离开来了。   这个回答很好:源于: https://zhidao.baidu.com/question/489425455706898652.html   运行机制就不大一样,jsp是编译成继承自servlet的 class文件 ,运行jsp就是运行一个servlet   而freemarker就是套模板,通过模板+内容直接生成HTML然后输出   从开发角度来说   freemarker 自带一套模板语言,语法实现更简单直观,而且可以通过marco宏编写控件,如果宏无法满足,freemarker也还提供了很多JAVA扩展接口。   而JSP不管JSTL还是其他,都是靠taglib实现的,taglib的效率其实并不高,所以在复杂页面的渲染上 ,freemarker会明显高于jsp   同时 ,freemarker也不仅仅局限于B/S应用,可以广泛应用到比如代码生成、票据打印模板等各个方面   jsp的功能在freemarker基本上都提供了,有jsp经验的上手会比较简单 servlet + freemarker:   导入freemarker jar包:  <dependency>

java使用Freemarker、Flying sauser生成pdf,中文不显示、设置页眉、换页、红色中文字体不能加粗显示、中文不能换行解决

微笑、不失礼 提交于 2021-02-13 21:40:52
因为做这个很坑,花了几天时间,终于爬出来了,为了实现功能,借鉴了很多代码,找起来很麻烦,现整合一下,方便使用,所以记录下。 首先上两个效果图: 需求图1: demo图2: 做了个demo导出pdf,demo的看不出换行,懒得去加数据了,所以把自己用的图发出来。 本人使用的jar包: freemarker-2.3.22.jar,flying-saucer-core-9.1.16.jar,flying-saucer-pdf-9.1.16.jar,itext-4.2.0.jar, serializer-2.7.1.jar(遇到java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker,丢失这个jar,可以加上去) jar包地址: maven repository 下载 因为工作上需要,第一次做导出pdf,word,然后入了Freemarker的坑。开始做pdf导出,由于项目中已经有了类似导出,我就用itextpdf来导出生成pdf,后面又需要生成word,在系统上没有发现类似功能,一直复制别人写的代码早就想练练手了,所以查阅了下生成word的几种方式,后面选了Freemarker,这是最简单的方式,也是很快就把word生成了。后面用户说这个pdf样式不合格,被怼了回来, 完成的比较匆忙,可能有很多itext

Cannot convert String to MultipartFile

主宰稳场 提交于 2021-02-08 11:35:52
问题 Please help me to resolve my problem! I have bootstrap fileinput, files are included: <link href="/assets/css/fileinput/fileinput.css" rel="stylesheet" type="text/css"> <link href="/assets/css/fileinput/fileinput-rtl.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/assets/js/fileinput/fileinput.js"></script> <script type="text/javascript" src="/assets/js/plugins/fileinput/piexif.js"></script> <script type="text/javascript" src="/assets/js/plugins/fileinput/sortable

How to properly group records when executing a <#list>

巧了我就是萌 提交于 2021-02-05 10:56:45
问题 New guy here. I have been building an advanced form in NetSuite (uses Freemarker) to display invoice data. Everything looks and works great, however, I want to group the invoice line items by location. I am using a simple <#list> loop to pull the line item records. I currently display the location on each line item. Code (formats/styles removed for simplicity): <table> <#list record.item as item> <tr> <td> ${item.location} </td> <td> ${item.description} </td> <td> ${item.quantity} </td> <td>

@ControllerAdvice全局异常拦截

谁都会走 提交于 2021-02-03 07:07:34
@ControllerAdvice 拦截异常并统一处理 在spring 3.2中,新增了@ControllerAdvice 注解,可以用于定义@ExceptionHandler、@InitBinder、@ModelAttribute,并应用到所有@RequestMapping中。参考: @ControllerAdvice 文档 一、介绍 创建 MyControllerAdvice,并添加 @ControllerAdvice注解。 package com.sam.demo.controller; import org.springframework.ui.Model; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; /** * controller 增强器 * @author sam * @since 2017/7/17 */ @ControllerAdvice public class MyControllerAdvice { /** * 应用到所有 @RequestMapping 注解方法,在其执行之前初始化数据绑定器 *

Autowiring of Freemarker configuration fails

こ雲淡風輕ζ 提交于 2021-01-27 20:39:12
问题 I trying to use Freemarker Templating Engine to send html formatted emails. I had to do this in several services. In one service, freemarker is working fine, but not in another one. But the code, relevant for freemarker, is actually the same. The autowiring of @Autowired private Configuration freeMarkerConfig; is not working in one service, but in another. The autowiring appears in an hierachy (e.g. controller autowires service, service autowires a mailservice, mailservice autowires another

test if string can be converted to a number in FreeMarker

给你一囗甜甜゛ 提交于 2021-01-27 07:20:27
问题 I am trying to test whether a string can be converted into a number in FreeMarker. For example, "123" and "3.14" can be converted, but "foo" can't. I know that I can test for this by using the number method on the string (e.g. "123"?number ) and seeing whether it produces an error, but I am looking for a way to test for this without causing an error. I tried ?matches("^\d+$") , and it works fine for integers, but I am looking for something that works on all numbers. I can probably do it using

test if string can be converted to a number in FreeMarker

五迷三道 提交于 2021-01-27 07:17:12
问题 I am trying to test whether a string can be converted into a number in FreeMarker. For example, "123" and "3.14" can be converted, but "foo" can't. I know that I can test for this by using the number method on the string (e.g. "123"?number ) and seeing whether it produces an error, but I am looking for a way to test for this without causing an error. I tried ?matches("^\d+$") , and it works fine for integers, but I am looking for something that works on all numbers. I can probably do it using

MyBatis-Plus使用(1)-概述+代码生成器

瘦欲@ 提交于 2021-01-20 07:42:26
MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 官网: https://mp.baomidou.com/ AutoGenerator 是 MyBatis-Plus 的代码生成器,通过 AutoGenerator 可以快速生成 Entity、Mapper、Mapper XML、Service、Controller 等各个模块的代码,极大的提升了开发效率。 参考文档: https://mybatis.plus/guide/generator.html MyBatis-Plus 从 3.0.3 之后移除了代码生成器与模板引擎的默认依赖,需要手动添加相关依赖: < dependency > < groupId > com.baomidou </ groupId > < artifactId > mybatis-plus-generator </ artifactId > < version > 3.2.0 </ version > </ dependency > 2.*的版本要引用这个依赖: < dependency > < groupId > com.baomidou </ groupId > < artifactId > mybatis-plus </ artifactId > <