当前位置: 首页>>代码示例>>Java>>正文


Java VelocityTemplateEngine类代码示例

本文整理汇总了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"));
	};
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:24,代码来源:Login.java

示例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"));
	};
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:8,代码来源:Login.java

示例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"));
	};
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:11,代码来源:WebConsole.java

示例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);
}
 
开发者ID:oleg-vasiliev,项目名称:sparkjava-boilerplate,代码行数:8,代码来源:ViewUtil.java

示例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());

    }
 
开发者ID:perwendel,项目名称:spark-template-engines,代码行数:10,代码来源:VelocityExample.java

示例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()));
}
 
开发者ID:travisspencer,项目名称:stockholm-java-meetup-java-spark-demo,代码行数:12,代码来源:Router.java

示例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"));
}
 
开发者ID:SonarSource,项目名称:source-graph-viewer,代码行数:5,代码来源:Viewer.java


注:本文中的spark.template.velocity.VelocityTemplateEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。