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

The following examples show how to use org.springframework.web.servlet.view.velocity.VelocityViewResolver. 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: VelocityConfiguration.java    From DCMonitor with MIT License 6 votes vote down vote up
@Bean
VelocityViewResolver velocityViewResolver() {
  VelocityViewResolver resolver = new VelocityViewResolver();
  resolver.setSuffix(this.environment.getProperty("suffix", ".vm"));
  resolver.setPrefix(this.environment.getProperty("prefix", "/public/"));
  // Needs to come before any fallback resolver (e.g. a
  // InternalResourceViewResolver)
  resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
  Properties p = new Properties();
  p.put(Velocity.FILE_RESOURCE_LOADER_PATH, "/public/");
  p.put("input.encoding", "utf-8");
  p.put("output.encoding", "utf-8");
  resolver.setAttributes(p);
  resolver.setContentType("text/html;charset=utf-8");
  return resolver;
}
 
Example #2
Source File: VelocityProperties.java    From velocity-spring-boot-project with Apache License 2.0 5 votes vote down vote up
public void applyToViewResolver(Object viewResolver) {
    invokeSuperApplyToViewResolverMethod(viewResolver);
    VelocityViewResolver resolver = (VelocityViewResolver) viewResolver;
    resolver.setToolboxConfigLocation(getToolboxConfigLocation());
    resolver.setDateToolAttribute(getDateToolAttribute());
    resolver.setNumberToolAttribute(getNumberToolAttribute());
}
 
Example #3
Source File: VelocityLayoutAutoConfiguration.java    From velocity-spring-boot-project with Apache License 2.0 5 votes vote down vote up
@Bean(name = VELOCITY_VIEW_RESOLVER_BEAN_NAME)
@ConditionalOnMissingBean(value = VelocityViewResolver.class)
public EmbeddedVelocityLayoutViewResolver embeddedVelocityLayoutViewResolver(
        VelocityLayoutProperties velocityLayoutProperties) {
    EmbeddedVelocityLayoutViewResolver resolver = new EmbeddedVelocityLayoutViewResolver();
    velocityLayoutProperties.applyToViewResolver(resolver);
    return resolver;
}
 
Example #4
Source File: Application.java    From boot-examples with Apache License 2.0 5 votes vote down vote up
@Bean
VelocityViewResolver velocityViewResolver() {
    VelocityViewResolver resolver = new VelocityViewResolver();
    resolver.setSuffix(this.environment.getProperty("suffix", ".vm"));
    resolver.setPrefix(this.environment.getProperty("prefix", "/templates/"));
    // Needs to come before any fallback resolver (e.g. a
    // InternalResourceViewResolver)
    resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
    return resolver;
}
 
Example #5
Source File: ViewResolverRegistry.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private VelocityRegistration() {
	super(new VelocityViewResolver());
	getViewResolver().setSuffix(".vm");
}
 
Example #6
Source File: ViewResolverRegistryTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void velocity() {
	this.registry.velocity().prefix("/").suffix(".vm").cache(true);
	VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
	checkPropertyValues(resolver, "prefix", "/", "suffix", ".vm", "cacheLimit", 1024);
}
 
Example #7
Source File: ViewResolverRegistryTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void velocityDefaultValues() {
	this.registry.velocity();
	VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
	checkPropertyValues(resolver, "prefix", "", "suffix", ".vm");
}