本文整理汇总了Java中spark.template.velocity.VelocityTemplateEngine类的典型用法代码示例。如果您正苦于以下问题:Java VelocityTemplateEngine类的具体用法?Java VelocityTemplateEngine怎么用?Java VelocityTemplateEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VelocityTemplateEngine类属于spark.template.velocity包,在下文中一共展示了VelocityTemplateEngine类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: form
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
public static Route form() {
return (req, res) -> {
ResultSet rs = SuperiorWeb.db.execQuery("SELECT * FROM users;");
boolean pass = false;
try {
while (rs.next()) {
System.out.println(rs.getString("username"));
System.out.println(rs.getString("password"));
if(rs.getString("username").equals(req.queryParams("username")) && rs.getString("password").equals(req.queryParams("password"))) {
pass = true;
}
}
rs.close();
} catch (SQLException e) {e.printStackTrace();}
if (!pass) {
return "TEST";
}
HashMap<String, Object> params = new HashMap<String, Object>();
System.out.println(req.queryParams("username"));
params.put("username", req.queryParams("username"));
return new VelocityTemplateEngine().render(new ModelAndView(params, "templates/login.html"));
};
}
示例2: request
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
public static Route request() {
return (req, res) -> {
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "samplename");
return new VelocityTemplateEngine().render(new ModelAndView(params, "templates/index.html"));
};
}
示例3: request
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
public static Route request() {
System.out.println("A");
return (req, res) -> {
System.out.println("B");
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "samplename");
//return "A";
return new VelocityTemplateEngine().render(new ModelAndView(params, "templates/webconsole.html"));
};
}
示例4: strictVelocityEngine
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
private static VelocityTemplateEngine strictVelocityEngine() {
VelocityEngine configuredEngine = new VelocityEngine();
configuredEngine.setProperty("runtime.references.strict", true);
configuredEngine.setProperty("resource.loader", "class");
configuredEngine.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
return new VelocityTemplateEngine(configuredEngine);
}
示例5: main
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
public static void main(String[] args) {
get("/hello", (request, response) -> {
Map<String, Object> model = new HashMap<>();
model.put("message", "Hello Velocity");
return new ModelAndView(model, "hello.vm"); // located in the resources directory
}, new VelocityTemplateEngine());
}
示例6: main
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
public static void main(String args[]) {
get("/hello", (request, response) -> {
Map<String, Object> model = new HashMap<>();
Map<String, String> data = new HashMap<>();
data.put("message", "Hello Velocity World");
data.put("att2", "Another attribute just to make sure it really works");
model.put("data", data);
model.put("title", "Example 07");
return new ModelAndView(model, "hello.vm");
}, new VelocityTemplateEngine());
}
开发者ID:travisspencer,项目名称:stockholm-java-meetup-java-spark-demo,代码行数:16,代码来源:Example07_VelocityExample.java
示例7: addRoute
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
private <T extends Controllable> void addRoute(String method, String path, String template, Class<T> controllerClass, PicoContainer appContainer)
{
addRoute(method, TemplateViewRouteImpl.create(path, (Request request, Response response) ->
{
Map<String, Object> model = new HashMap<>();
router(controllerClass, appContainer, model, request, response);
return new ModelAndView(model, template);
}, new VelocityTemplateEngine()));
}
示例8: renderWithValues
import spark.template.velocity.VelocityTemplateEngine; //导入依赖的package包/类
private static String renderWithValues(String javaCode, Map<String, String> values) {
values.put("javaCode", javaCode);
return new VelocityTemplateEngine().render(new ModelAndView(values, "velocity/index.vm"));
}