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


Java VelocityConfigurer类代码示例

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


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

示例1: velocityConfig

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
	public VelocityConfigurer velocityConfig() {
		VelocityConfigurer cfg = new VelocityConfigurer();
		cfg.setResourceLoaderPath("/WEB-INF/velocity/");
		cfg.setPreferFileSystemAccess(true);
//		cfg.setConfigLocation(context.getResource("/WEB-INF/velocity.properties"));
		Properties velocityProperties = new Properties();
//		velocityProperties.put("velocimacro.permissions.allow.inline", "true");
//		velocityProperties.put("velocimacro.permissions.allow.inline.to.replace.global", "true");
//		velocityProperties.put("velocimacro.permissions.allow.inline.local.scope", "true");
//		velocityProperties.put("input.encoding", "UTF-8");
//		velocityProperties.put("output.encoding", "UTF-8");
//		velocityProperties.put("resource.loader", "webapp, class");
//		velocityProperties.put("class.resource.loader.description", "Velocity Classpath Resource Loader");
//		velocityProperties.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ");
//		velocityProperties.put("webapp.resource.loader.class", "org.apache.velocity.tools.view.WebappResourceLoader");
//		velocityProperties.put("webapp.resource.loader.path", "/WEB-INF/velocity/");
//		velocityProperties.put("webapp.resource.loader.cache", "true");
		cfg.setVelocityProperties(velocityProperties);
		
		return cfg;
	}
 
开发者ID:gleb619,项目名称:hotel_shop,代码行数:23,代码来源:VelocityConfig.java

示例2: velocityConfig

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
public VelocityConfig velocityConfig() throws IOException, VelocityException {
    Properties config = new Properties();
    config.setProperty("input.encoding", "UTF-8");
    config.setProperty("output.encoding", "UTF-8");
    config.setProperty("default.contentType", "text/html;charset=UTF-8");
    config.setProperty("resource.loader", "class");
    config.setProperty("class.resource.loader.class",
            "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setVelocityProperties(config);
    velocityConfigurer.afterPropertiesSet();

    return velocityConfigurer;
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:17,代码来源:SpringConfig.java

示例3: velocityConfigurer

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:8,代码来源:VelocityAutoConfiguration.java

示例4: velocity

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
/**
 * Register Velocity view resolver with an empty default view name
 * prefix and a default suffix of ".vm".
 *
 * <p><strong>Note</strong> that you must also configure Velocity by adding a
 * {@link org.springframework.web.servlet.view.velocity.VelocityConfigurer} bean.
 */
public UrlBasedViewResolverRegistration velocity() {
	if (this.applicationContext != null && !hasBeanOfType(VelocityConfigurer.class)) {
		throw new BeanInitializationException("In addition to a Velocity view resolver " +
				"there must also be a single VelocityConfig bean in this web application context " +
				"(or its parent): VelocityConfigurer is the usual implementation. " +
				"This bean may be given any name.");
	}
	VelocityRegistration registration = new VelocityRegistration();
	this.viewResolvers.add(registration.getViewResolver());
	return registration;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:ViewResolverRegistry.java

示例5: setUp

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Before
public void setUp() {
	StaticWebApplicationContext context = new StaticWebApplicationContext();
	context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
	context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
	context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
	context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
	context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);
	this.registry = new ViewResolverRegistry();
	this.registry.setApplicationContext(context);
	this.registry.setContentNegotiationManager(new ContentNegotiationManager());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:ViewResolverRegistryTests.java

示例6: velocityConfigurer

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
	VelocityConfigurer configurer = new VelocityConfigurer();
	applyProperties(configurer);
	return configurer;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:VelocityAutoConfiguration.java

示例7: customVelocitySettings

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Test
public void customVelocitySettings() {
	registerAndRefreshContext(
			"spring.velocity.properties.directive.parse.max.depth:10");
	assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
			.getProperty("directive.parse.max.depth")).isEqualTo("10");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:VelocityAutoConfigurationTests.java

示例8: renderTemplate

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Test
public void renderTemplate() throws Exception {
	registerAndRefreshContext();
	VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class);
	StringWriter writer = new StringWriter();
	Template template = velocity.getVelocityEngine().getTemplate("message.vm");
	template.process();
	VelocityContext velocityContext = new VelocityContext();
	velocityContext.put("greeting", "Hello World");
	template.merge(velocityContext, writer);
	assertThat(writer.toString()).contains("Hello World");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:VelocityAutoConfigurationTests.java

示例9: velocityConfigurer

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
/**
 * 过期是由于velocity六年没有更新过了,spring官方推荐使用FreeMarker或者Thymeleaf
 *
 * @return
 */
@Bean(name = "velocityConfig")
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    configurer.setResourceLoaderPath("/WEB-INF/template/");
    Properties properties = new Properties();

    //解决乱码问题
    properties.setProperty("input.encoding", "utf-8");
    properties.setProperty("output.encoding", "utf-8");
    configurer.setVelocityProperties(properties);
    return configurer;
}
 
开发者ID:hadesvip,项目名称:ssm-shiro,代码行数:18,代码来源:MVConfig.java

示例10: customVelocitySettings

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Test
public void customVelocitySettings() {
	registerAndRefreshContext(
			"spring.velocity.properties.directive.parse.max.depth:10");
	assertThat(
			this.context.getBean(VelocityConfigurer.class).getVelocityEngine()
					.getProperty("directive.parse.max.depth"),
			equalTo((Object) "10"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:VelocityAutoConfigurationTests.java

示例11: renderTemplate

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Test
public void renderTemplate() throws Exception {
	registerAndRefreshContext();
	VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class);
	StringWriter writer = new StringWriter();
	Template template = velocity.getVelocityEngine().getTemplate("message.vm");
	template.process();
	VelocityContext velocityContext = new VelocityContext();
	velocityContext.put("greeting", "Hello World");
	template.merge(velocityContext, writer);
	assertThat(writer.toString(), containsString("Hello World"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:VelocityAutoConfigurationTests.java

示例12: velocityConfig

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
public VelocityConfig velocityConfig()
{
    Properties p = new Properties();
    p.put( "resource.loader", "webapp" );
    p.put( "webapp.resource.loader.path", new File( webapp, "html" ).toString() );
    p.put( "webapp.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader" );
    VelocityConfigurer vc = new VelocityConfigurer();
    VelocityEngine engine = new VelocityEngine( p );
    engine.init();
    vc.setVelocityEngine( engine );
    return vc;
}
 
开发者ID:cherimojava,项目名称:orchidae,代码行数:14,代码来源:WebMvcConfig.java

示例13: velocityEngine

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:6,代码来源:VelocityAutoConfiguration.java

示例14: velocityConfigurer

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
public VelocityConfigurer velocityConfigurer() {
	VelocityConfigurer configurer = new VelocityConfigurer();
	configurer.setResourceLoaderPath("/WEB-INF/");
	return configurer;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:ViewResolutionIntegrationTests.java

示例15: velocityConfigurer

import org.springframework.web.servlet.view.velocity.VelocityConfigurer; //导入依赖的package包/类
@Bean
public VelocityConfigurer velocityConfigurer() {
	return new VelocityConfigurer();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:EmbeddedVelocityToolboxViewTests.java


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