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

The following examples show how to use org.springframework.web.servlet.view.velocity.VelocityConfigurer. 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 File: SpringConfig.java    From quartz-glass with 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
Source File: VelocityAutoConfiguration.java    From velocity-spring-boot-project with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(VelocityConfig.class)
public VelocityConfigurer velocityConfigurer() {
    VelocityConfigurer configurer = new VelocityConfigurer();
    applyProperties(configurer);
    return configurer;
}
 
Example #3
Source File: ViewResolverRegistry.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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
Source File: ViewResolverRegistryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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
Source File: VelocityAutoConfiguration.java    From velocity-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Bean
public VelocityEngine velocityEngine(VelocityConfigurer configurer)
        throws VelocityException, IOException {
    return configurer.getVelocityEngine();
}
 
Example #6
Source File: ViewResolutionIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public VelocityConfigurer velocityConfigurer() {
	VelocityConfigurer configurer = new VelocityConfigurer();
	configurer.setResourceLoaderPath("/WEB-INF/");
	return configurer;
}
 
Example #7
Source File: VelocityConfiguration.java    From DCMonitor with MIT License 4 votes vote down vote up
@Bean
VelocityConfigurer velocityConfig() {
  return new VelocityConfigurer();
}
 
Example #8
Source File: Application.java    From boot-examples with Apache License 2.0 4 votes vote down vote up
@Bean
VelocityConfigurer velocityConfig() {
    return new VelocityConfigurer();
}
 
Example #9
Source File: WebConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}
 
Example #10
Source File: TestConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public VelocityConfigurer velocityConfig() {
    VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
    velocityConfigurer.setResourceLoaderPath("/");
    return velocityConfigurer;
}