Created
October 5, 2012 08:47
-
-
Save 6LYTH3/3838803 to your computer and use it in GitHub Desktop.
Test Freemarker into java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com; | |
import java.io.IOException; | |
import java.io.OutputStreamWriter; | |
import java.io.Writer; | |
import java.util.HashMap; | |
import java.util.Map; | |
import freemarker.template.Configuration; | |
import freemarker.template.Template; | |
import freemarker.template.TemplateException; | |
public class hello { | |
/** | |
* @param args | |
* @throws IOException | |
*/ | |
public static void main(String[] args) throws IOException, TemplateException { | |
// configuration | |
Configuration cfg = new Configuration(); | |
Template template = cfg.getTemplate("src/templat/helloTemplat.ftl"); | |
// logic | |
Map<String, Object> data = new HashMap<String, Object>(); | |
data.put("user", "Blythe Intown"); | |
// Console output | |
Writer out = new OutputStreamWriter(System.out); | |
template.process(data, out); | |
out.flush(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Welcome !!</title> | |
</head> | |
<body> | |
<h1>welcome ${user}</h1> | |
</body> | |
</html> |
มาดูทั้งแต่เมื่อไหร่ เขิน ^^
มาดูตั้งแต่เมื่อไหร่ ^^ เขิน
เขิน
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
^_^