Java Code Examples for org.springframework.web.servlet.view.velocity.VelocityConfigurer

The following examples show how to use org.springframework.web.servlet.view.velocity.VelocityConfigurer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: quartz-glass   Source File: SpringConfig.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
 
Example 3
/**
 * 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;
}
 
Example 4
@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());
}
 
Example 5
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
 
Example 6
@Bean
public VelocityConfigurer velocityConfigurer() {
	VelocityConfigurer configurer = new VelocityConfigurer();
	configurer.setResourceLoaderPath("/WEB-INF/");
	return configurer;
}
 
Example 7
Source Project: DCMonitor   Source File: VelocityConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
VelocityConfigurer velocityConfig() {
  return new VelocityConfigurer();
}
 
Example 8
Source Project: boot-examples   Source File: Application.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
VelocityConfigurer velocityConfig() {
    return new VelocityConfigurer();
}
 
Example 9
Source Project: tutorials   Source File: WebConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}
 
Example 10
Source Project: tutorials   Source File: TestConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}