spring下配置一个新的velocity engine
来源:互联网 发布:如何防止网络渗透策反 编辑:程序博客网 时间:2024/05/22 05:14
applicatioin-context.xml
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"><property name="velocityProperties"><props><prop key="resource.loader">file</prop><prop key="file.resource.loader.path">.</prop><prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop><prop key="input.encoding">UTF-8</prop><prop key="output.encoding">UTF-8</prop></props></property></bean>
invite_email.vm
<br>$name<br>$content<br><img src="$img"/>
Test
@Testpublic void testMergeTemplateIntoString() {Map<String, String> map = new HashMap<String, String>();map.put("name", "张三");map.put("content", "This is content!!!");map.put("img", "http://www.iknowing.com/photos/1/1/1.jpg");String vm = "invite_email.vm";String html = templateService.mergeTemplateIntoString(vm, map);System.out.println(html);}
TemplateService
private static String tplFolder = "templates/";@Autowiredprivate VelocityEngine velocityEngine;@Overridepublic String mergeTemplateIntoString(String vm, Map<String, String> map) {String tpl = tplFolder + vm;return VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, tpl, map);}
- spring下配置一个新的velocity engine
- spring中velocity的配置
- Spring MVC+Maven+Velocity的配置过程
- Spring+Mybatis+Velocity配置
- Spring MVC配置Velocity
- struts2下配置velocity
- Spring中配置Velocity模板
- spring mvc 与velocity配置
- spring mvc 配置 velocity 模板
- Spring MVC中配置Velocity
- Velocity 在Spring中的配置
- Insight Spring Velocity相关配置以及缓存的设计
- spring下使用velocity的中文乱码问题
- Velocity初探小结--Velocity在spring中的配置和使用
- linux下调用matlab的engine的环境配置
- 【笔记】Velocity模板 和 Spring的整合配置 解决页面乱码的最佳方案, 简单Demo了解Velocity
- Velocity基于java的模板引擎(template engine)
- struts+spring+ibatis+velocity整合配置
- PHP编码转换
- Makefile模版
- 润乾模板
- 无法加载 DLL“rasapi32.dll”的问题的解决方法
- epoll和select/poll的区别
- spring下配置一个新的velocity engine
- hdu 1034 Candy Sharing Game
- jQuery方法大全
- js中常用的一些方法收集
- .net mvc3.0 中接收 json 数据,并转换为自定义的 C# 对象
- wine的./configure检查配置时的报错
- div后台加入html文件
- struts2 验证码例子
- VS2010 Beta2中,4个重要的新特性。号称C++0x的“四大天王”