velocity

Spring与后端模板引擎的故事

≯℡__Kan透↙ 提交于 2019-11-28 19:14:53
更多内容,欢迎关注微信公众号:全菜工程师小辉。公众号回复关键词,领取免费学习资料。 现在很多开发,都采用了前后端完全分离的模式,随着近几年前端工程化工具和MVC框架的完善,使得这种模式的维护成本逐渐降低。但是这种模式目前并不利于SEO(前后端分离的SEO问题会慢慢改善),而且某些场景使用模板引擎会更方便,比如说邮件模板以及数据变化不频繁的后台系统。 Spring,确切来说是Spring MVC除了可以实现RESTful web服务之外,还可以使用它提供动态HTML内容。Spring MVC支持多种模板技术,包括Thymeleaf、FreeMarker和JSP等。 什么是模板引擎? 模板引擎(这里特指用于Web开发的模板引擎)是为了使用户界面与业务数据(内容)分离而产生的,它可以生成特定格式的文档,用于网站的模板引擎就会生成一个标准的文档。 模板引擎的基本机理就是替换(转换),将指定的标签转换为需要的业务数据;将指定的伪语句按照某种流程来变换输出。 SpringMVC和模板引擎的关系 SpringMVC处理请求的流程图: 模板引擎发挥作用是在第8,9,10步骤。 更详细的原理介绍,点我跳转 版本支持 重点介绍Velocity,因为其2010年以后连续6年没有更新,版本停留在1.7,直到最近两年才有更新,最新版本是2019年3月更新的2.1,但是变化并不大。 Spring官网原文:

Replacing variables in a word document template with java

不羁岁月 提交于 2019-11-28 17:06:33
I want to load a template word document to add content to and save as new document. I'm working on .doc file. After a long research I only found solutions for docx : http://www.smartjava.org/content/create-complex-word-docx-documents-programatically-docx4j http://www.sambhashanam.com/mail-merge-in-java-for-microsoft-word-document-part-i/ So I want to replace any variable written in this format: $VAR by its value. Can I do it with velocity or Apache-poi, what is the best solution for it. Any help will be appreciated. Yes, you can do it using Apache-POI. Your variable names must be unique. See

struts2整合velocity

ε祈祈猫儿з 提交于 2019-11-28 15:47:52
web.xml文件: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns=" http://java.sun.com/xml/ns/javaee " xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "> <filter> <filter-name>Struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>Struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>velocity</servlet-name> <servlet-class>

Why would I use a templating engine? jsp include and jstl vs tiles, freemarker, velocity, sitemesh

二次信任 提交于 2019-11-28 15:10:36
I'm about to choose to way to organize my view (with spring-mvc, but that shouldn't matter much) There are 6 options as far as I see (though they are not mutually exclusive): Tiles Sitemesh Freemarker Velocity <jsp:include> <%@ include file=".."> Tiles and Sitemesh can be grouped; so can Freemarker and Velocity . Which one within each group to use is not a matter of this discussion, there are enough questions and discussions about it. This is an interesting read , but can't quite convince me to use tiles. My question is - what do these frameworks give that can't be properly done with <@

Could not find org.springframework.boot:spring-boot-starter-velocity

假装没事ソ 提交于 2019-11-28 14:09:07
I'm new to spring and trying to use velocity with spring boot. Here is my build.gradle repositories { mavenCentral() } plugins { id 'org.springframework.boot' version '2.0.4.RELEASE' } apply plugin: 'java' apply plugin: 'eclipse-wtp' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'war' dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.boot:spring-boot-starter-velocity') runtime('org.springframework.boot:spring-boot-devtools') providedRuntime('org.springframework.boot:spring-boot

gof-组件模式

Deadly 提交于 2019-11-28 13:44:33
应用场景:类关联的域比较多,功能过多 你懒通过多重继承实现功能细分时 体验:逻辑更有层次感,功能迭代更加便捷,运维难度-1 using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace ComponentPatter_original { public class World { public void resolveCollision(int x,int y,int z) { } } public class Graphic { public void draw(int x,int y) { } } public static class InputInfo { public static int GetJoyDirection() { return 0; } } public class Bjron { private static readonly int WALK_ACCCELERATION = 1; private int x, y, velocity; private Sprite stand, walkLeft, walkRight; public Bjron():this(0,0,0) {} public Bjron(int

Velocity Template engine - key-value-map

南笙酒味 提交于 2019-11-28 13:25:49
I have some problems wo use a key-value-map into Velocity. Someone has an example of this functionality? $myMap ={} $myMap.put("mykey1", "myvalue") $myMap.delete("mykey1") $myMap.getValue("mykey1") As Nathan said, you should use: #set ($myMap = {}) to create a new map and assign it to a variable. Now, why is the put call printed. Anything that is not inside a directive, like #set(not printed) or #if(not printed) or #foreach(again not printed) , is printed, including free text, variables, and method calls . Velocity can't distinguish between $myMap.get('mykey') and $myMap.put('key', 'value') ,

How to append hash tables in velocity template?

别等时光非礼了梦想. 提交于 2019-11-28 12:19:45
问题 I tried to append two hash tables in velocity. #foreach($dun1 in $dotcontent.pull("+structureName:Checnas +(conhost:fe1d98e8-9699-4f3f-abf5-a6c0afc8ab47 conhost:SYSTEM_HOST)",10,"modDate desc")) #set($foo={ $!{dun1.mname}:$!{dun1.subname} }) #end In the above for each loop I am pulling content from structure " Checnas ". But at the end we can get only the last value in the content.To solve that we need to append for every iteration.I need syntax for appending hash tables. Please help me to

Cocos2dx - Unable to set velocity = 0.0

你离开我真会死。 提交于 2019-11-28 11:35:04
问题 I'm making an pool game with cocos2dx. First, i setup the edgeBox with this parameters PhysicsMaterial(1.0f, 1.0f, 0.8f) And then these 2 balls PhysicsMaterial(1.0f, 1.0f, 0.5f) On the update function, i want slow down balls time by time without gravity (like making ground friction) by adding physicsBody->setLinearDamping(0.3); On the update function, i set the minimum velocity, if the velocity of each ball reaches lower than 15, reset velocity to 0,0 auto MV = 15; auto v1 = player1-

Velocity can't find resource

老子叫甜甜 提交于 2019-11-28 09:05:39
Something is wrong and it is very frustrating. I read on velocity's homepage that when I run a webapp then some properties should be set. And I've done that but no matter what I do I keep getting the same error. This is where I set the props and use velocity public class ConfirmationMailGenerator implements MailGenerator { private BasicUser user; private String htmlTemplate = "HTMLConfirmationMailTemplate.vsl"; private String plainTemplate = "PlainConfirmationMailTemplate.vsl"; public ConfirmationMailGenerator(BasicUser user) { this.user = user; } public StringWriter generateHTML() throws