Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Created October 5, 2012 08:47
Show Gist options
  • Save 6LYTH3/3838803 to your computer and use it in GitHub Desktop.
Save 6LYTH3/3838803 to your computer and use it in GitHub Desktop.
Test Freemarker into java
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();
}
}
<html>
<head>
<title>Welcome !!</title>
</head>
<body>
<h1>welcome ${user}</h1>
</body>
</html>
@Duck-ComEn
Copy link

^_^

@6LYTH3
Copy link
Author

6LYTH3 commented Oct 12, 2012

มาดูทั้งแต่เมื่อไหร่ เขิน ^^

@6LYTH3
Copy link
Author

6LYTH3 commented Oct 12, 2012

มาดูตั้งแต่เมื่อไหร่ ^^ เขิน

@6LYTH3
Copy link
Author

6LYTH3 commented Oct 12, 2012

เขิน

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment