类org.springframework.web.servlet.view.velocity.VelocityConfigurer源码实例Demo

下面列出了怎么用org.springframework.web.servlet.view.velocity.VelocityConfigurer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: quartz-glass   文件: SpringConfig.java
@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;
}
 
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
 
/**
 * 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;
}
 
@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());
}
 
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
 
@Bean
public VelocityConfigurer velocityConfigurer() {
	VelocityConfigurer configurer = new VelocityConfigurer();
	configurer.setResourceLoaderPath("/WEB-INF/");
	return configurer;
}
 
源代码7 项目: DCMonitor   文件: VelocityConfiguration.java
@Bean
VelocityConfigurer velocityConfig() {
  return new VelocityConfigurer();
}
 
源代码8 项目: boot-examples   文件: Application.java
@Bean
VelocityConfigurer velocityConfig() {
    return new VelocityConfigurer();
}
 
源代码9 项目: tutorials   文件: WebConfig.java
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}
 
源代码10 项目: tutorials   文件: TestConfig.java
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}
 
 类方法
 同包方法