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


Java VelocityContext类代码示例

本文整理汇总了Java中org.apache.velocity.VelocityContext的典型用法代码示例。如果您正苦于以下问题:Java VelocityContext类的具体用法?Java VelocityContext怎么用?Java VelocityContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VelocityContext类属于org.apache.velocity包,在下文中一共展示了VelocityContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		String file=req.getParameter("file");
		String project = buildProjectNameFromFile(file);
		if(project!=null){
			context.put("project", project);
		}
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/decisiontable-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:DecisiontableEditorServletHandler.java

示例2: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/variable-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:VariableEditorServletHandler.java

示例3: usage1

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
public void usage1(String inputFile) throws FileNotFoundException {
   Velocity.init();

    VelocityContext context = new VelocityContext();

    context.put("author", "Elliot A.");
    context.put("address", "217 E Broadway");
    context.put("phone", "555-1337");

    FileInputStream file = new FileInputStream(inputFile);

    //Evaluate
    StringWriter swOut = new StringWriter();
    Velocity.evaluate(context, swOut, "test", file);

    String result =  swOut.getBuffer().toString();
    System.out.println(result);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:19,代码来源:VelocityUsage.java

示例4: generate

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
/**
 * 根据模板生成文件
 * @param inputVmFilePath 模板路径
 * @param outputFilePath 输出文件路径
 * @param context
 * @throws Exception
 */
public static void generate(String inputVmFilePath, String outputFilePath, VelocityContext context) throws Exception {
	try {
		Properties properties = new Properties();
		properties.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, getPath(inputVmFilePath));
		Velocity.init(properties);
		//VelocityEngine engine = new VelocityEngine();
		Template template = Velocity.getTemplate(getFile(inputVmFilePath), "utf-8");
		File outputFile = new File(outputFilePath);
		FileWriterWithEncoding writer = new FileWriterWithEncoding(outputFile, "utf-8");
		template.merge(context, writer);
		writer.close();
	} catch (Exception ex) {
		throw ex;
	}
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:23,代码来源:VelocityUtil.java

示例5: processDynamicWebProject

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
private void processDynamicWebProject(VelocityContext context, String rootPath, String projectName) throws Exception {
	File file = new File(rootPath + File.separator + projectName);
	file.renameTo(new File(rootPath + File.separator + projectName + "-bak"));

	WizardFileUtils.copyDirectiory(dynamicWebTemplatePath, rootPath + File.separator + projectName);
	String destProjectFilePath = rootPath + File.separator + projectName + File.separator + ".project";

	VelocityUtils.velocityEvaluate(context, dynamicWebProjectVmFile, destProjectFilePath);
	String wstCommonComponentFilePath = rootPath + File.separator + projectName + File.separator + ".settings" + File.separator + "org.eclipse.wst.common.component";
	VelocityUtils.velocityEvaluate(context, wstCommonComponentVmFile, wstCommonComponentFilePath);

	StringWriter writer = new StringWriter();
	String outputDirectory = rootPath + File.separator + projectName + File.separator + "web" + File.separator + "WEB-INF" + File.separator + "lib";
	context.put("outputDirectory", outputDirectory);
	VelocityUtils.velocityEvaluate(context, pomBuildVmFile, writer);

	String pomPath = rootPath + File.separator + projectName + "-bak" + File.separator + "pom.xml";
	this.addPomFileBuildElement(writer.toString(), pomPath);
	mavenCompiler.execute(pomPath);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:ProjectBuilder.java

示例6: testApp

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Test
@Ignore
public void testApp() throws IOException {

    Properties props = new Properties();
    props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("velocity.properties"));
    VelocityEngine ve = new VelocityEngine(props);
    ve.init();

    Template t = ve.getTemplate("/templates/registry.vm");
    VelocityContext context = new VelocityContext();

    context.put("username", "ricky");
    context.put("url", "http://www.thymeleaf.org");
    context.put("email", "[email protected]");

    StringWriter writer = new StringWriter(1024);
    t.merge(context, writer);

    String output = writer.toString();
    System.out.println(output);
}
 
开发者ID:TFdream,项目名称:okmail,代码行数:23,代码来源:VelocityTest.java

示例7: writePom

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
protected void writePom(String srcPom, String destPom, String project, String packagePath) throws IOException {
    Template tempate = VelocityUtil.getTempate(srcPom);
    VelocityContext ctx = new VelocityContext();
    ctx.put("packagePath", packagePath);
    ctx.put("project", project);
    ctx.put("application", packagePath + "." + this.applicationName);
    ctx.put("driverClass", driverClass);
    ctx.put("serviceProject", serviceProject);
    ctx.put("serviceApiProject", serviceApiProject);
    ctx.put("parentProject", parentProject);
    ctx.put("springCloudVersion", springCloudVersion);
    ctx.put("springBootVersion", springBootVersion);
    for (Map.Entry<String, Object> entry : options.entrySet()) {
        ctx.put(entry.getKey(), entry.getValue());
    }
    StringWriter writer = new StringWriter();
    tempate.merge(ctx, writer);
    writer.close();
    write(writer.toString(), destPom);
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:21,代码来源:AbstractGenerator.java

示例8: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/constant-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:ConstantServletHandler.java

示例9: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		String file=req.getParameter("file");
		String project = buildProjectNameFromFile(file);
		if(project!=null){
			context.put("project", project);
		}
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/scriptdecisiontable-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:ScriptDecisiontableEditorServletHandler.java

示例10: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	if(!((PermissionService)permissionStore).isAdmin()){
		throw new NoPermissionException();
	}
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/permission-config-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:20,代码来源:PermissionConfigServletHandler.java

示例11: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		String file=req.getParameter("file");
		String project = buildProjectNameFromFile(file);
		if(project!=null){
			context.put("project", project);
		}
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/decisiontree-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:DecisionTreeEditorServletHandler.java

示例12: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		String file=req.getParameter("file");
		String project = buildProjectNameFromFile(file);
		if(project!=null){
			context.put("project", project);
		}
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/rule-flow-designer.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:RuleFlowDesignerServletHandler.java

示例13: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/parameter-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:ParameterServletHandler.java

示例14: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String key=req.getParameter("key");
	String msg=null;
	if(StringUtils.isBlank(key)){
		msg="<h2 style='color:red'>请指定要查看的调试消息的key值</h2>";
	}else{
		msg=debugMessageHolder.getDebugMessage(key);
	}
	VelocityContext context = new VelocityContext();
	context.put("title", "URule Console");
	context.put("msg", msg);
	resp.setContentType("text/html");
	resp.setCharacterEncoding("utf-8");
	Template template=ve.getTemplate("html/console.html","utf-8");
	PrintWriter writer=resp.getWriter();
	template.merge(context, writer);
	writer.close();
}
 
开发者ID:youseries,项目名称:urule,代码行数:20,代码来源:ConsoleServletHandler.java

示例15: execute

import org.apache.velocity.VelocityContext; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/client-config-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:ClientConfigServletHandler.java


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