velocity

JS/ CSS files not found due to path differences java, spring mvc, velocity

二次信任 提交于 2019-12-06 19:34:26
I have this directory structure: webapp - resources - custom.js - base.css - WEB-INF - views - layout.vm - top.vm - footer.vm - index.vm - FolderA - restricted.vm My layout.vm is: #parse('top.vm') $screen_content #parse('footer.vm') My top.vm consists include these JS and CSS files: <link href="resources/base.css" rel="stylesheet"> <script src="resources/custom.js"></script> Now when my I access http://www.example.com:8080/index page, I see the JS and CSS files getting found. But when I visit http://www.example.com:8080/FolderA/restricted , JS and CSS files are not found. It works when in top

Using velocity split() to split a string into an array doesnt seem to work

怎甘沉沦 提交于 2019-12-06 19:04:44
问题 I HATE velocity and rarely ever use it but sometimes I am called upon at my job to do so. I can never really figure out just how to use it. I have this #foreach( $product in $browseSiteProducts ) alert("$product.productId"); #foreach( $stringList in $product.productId.split("|") ) alert("inner loop"); #end #end $browseSiteProducts is an Array. Or List. Or whatever. I don't even know. The first alert of the productId works fine. I get "|" which is what I expected when printed out. The inner

Why Velocity support is deprecated in Spring 4.3?

你离开我真会死。 提交于 2019-12-06 18:18:06
问题 And how are we going to use Velocity with Spring after Spring 5.0? 回答1: It looks like Jürgen Höller wants to get rid of Velocity alltogether, because it "dates back to 2010". Support for it was deprecated in Spring 4.3, and will probably be removed in Spring 5. https://jira.spring.io/browse/SPR-13795 回答2: In the accepted answer from @Olivier Croisier he states that the reason for depracating velocity was that it "dates back to 2010". While this doesn't seem a particularly valid reason to get

How to disable velocity logs

跟風遠走 提交于 2019-12-06 17:58:31
问题 I've been trying to disable Velocity logs, and the only way I've found so far with positive results is to set: runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem but inside the velocity.properties that resides inside the velocity.jar. I'm using velocity in a Web Application (tomcat) context. Is there any way to disable the velocity (by setting the previous property or whatever) BUT without modifying the JAR?? Cannot modify any CODE Thanks in advance 回答1: In general :

Accessing constant values from an Apache Velocity template?

半城伤御伤魂 提交于 2019-12-06 17:40:59
问题 Is it possible to access a constant value (i.e. a public static final variable defined in a Java class) from a Velocity template? I would like to be able to write something like this: #if ($a lt Long.MAX_VALUE) but this is apparently not the right syntax. 回答1: There are a number of ways. 1) You can put the values directly in the context. 2) You can use the FieldMethodizer to make all public static fields in a class available. 3) You can use a custom Uberspect implementation that includes

Velocity (VM) template request parameters: Getting GET variables

此生再无相见时 提交于 2019-12-06 16:14:27
How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing template: <br><br><br> #set($url = $request.attributes.CURRENT_URL) <h2>url: $url</h2> #set($favs = $url.split("fav=")) favs: $favs<br> favs.size(): $favs.size() <br> #if($favs.size() > 1) #set($fav1 = $favs.get(1).split("&").get(0)) fav1: $fav1<br> #else No fav! #end #if($favs.size() > 2) #set($fav2 = $favs.get(2).split("&").get(0)) fav2: $fav2<br> #end

How to add html image in to velocity template file to send email?

爷,独闯天下 提交于 2019-12-06 15:19:20
I include this in my velocity file. but it is not working, < img src="cid:src/resources/imageContent.jpg" /> You can follow the guide here . For example, try this in your Velocity template file: <img src = "cid:${cid}" alt = "Foo"> And in your Java code, try: URL url = new URL("image.png"); String cid = email.embed(url, "Foo"); Map model = new HashMap(); model.put("cid", cid); Darshit When your server is running you can get path till server from request.getContexPath(); So here you just need to provide rest path of the image. I have done this for my demo application like this. <img border="0"

use velocity template engine in js page

流过昼夜 提交于 2019-12-06 09:41:48
i know there's some nodejs modules to use apache velocity in node like those addresses in that question's response. could be done to use it as a, says, mustache replacement via, maybe, browserify.js? how would you do that as a workflow? I suspect it would be a better implementation on Liferay's frontend template development, so the frontender can serve to the java team html already velocity templating aware. Thanks a lot. You can directly use velocityjs on browser after using browserify on it. Installation First install velocityjs in your node_modules $> npm install velocityjs Now from your

Java Robot mouse move: setting speed?

泄露秘密 提交于 2019-12-06 06:43:59
问题 The Java Robot class allows one to move the mouse as if the actual physical mouse was moved. However, how does one move the mouse from Point1 to Point2 in a humane (and thus not instant) manner? Aka, how does one set the speed of movement? If no such speed is possible with the Robot class, thus if the mouse can only be moved instantenously, what kind of "algorithm" should be used to mimic a human's mouse movement? Should it move the mouse pixel by pixel with a certain incrementing speed? 回答1:

How to round off decimal number to 2 places in Velocity template engine?

爱⌒轻易说出口 提交于 2019-12-06 05:29:45
How can i round off decimal number to 2 places in Velocity Template Engine? #set ($Percentage = $Marks*100/$Total) I want to round off Percentage to 2 decimal places. How can i do that? will Double roundTo(Object decimals, Object num) this work? i.e. will #set ($Percentage = roundTo(2, $Marks*100/$Total)) work? will I have to include anything in .vm file to make this work? Nathan Bubna Use the MathTool from the VelocityTools project. $math.roundTo(2, $value) remember to put the MathTool in your context: context.put("math", new MathTool()) or use VelocityTools context support to automatically