本文整理汇总了Java中org.springframework.web.servlet.view.velocity.VelocityViewResolver类的典型用法代码示例。如果您正苦于以下问题:Java VelocityViewResolver类的具体用法?Java VelocityViewResolver怎么用?Java VelocityViewResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VelocityViewResolver类属于org.springframework.web.servlet.view.velocity包,在下文中一共展示了VelocityViewResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: viewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
/**
* 视图解析器
* velocity
* 过期是由于velocity六年没有更新过了,spring官方推荐使用FreeMarker或者Thymeleaf
* 后期考虑spring官方的Thymeleaf
*/
@Bean
public ViewResolver viewResolver() {
/* InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setContentType("text/html;charset=utf-8");
viewResolver.setPrefix("/static/");
viewResolver.setSuffix(".html");
return viewResolver;*/
VelocityViewResolver velocityViewResolver = new VelocityViewResolver();
velocityViewResolver.setCache(true);
velocityViewResolver.setPrefix("");
velocityViewResolver.setSuffix(".html");
velocityViewResolver.setContentType("text/html;charset=utf-8");
//关于Toolbox路径问题:如何路径开始头没有/会自动加上/,所以你如果写classpath:之类的识别不了
velocityViewResolver.setToolboxConfigLocation("/WEB-INF/velocityToolBox.xml");
velocityViewResolver.setViewClass(VelocityToolboxView.class);
return velocityViewResolver;
}
示例2: velocityViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@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;
}
示例3: applyToViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Override
public void applyToViewResolver(Object viewResolver) {
super.applyToViewResolver(viewResolver);
VelocityViewResolver resolver = (VelocityViewResolver) viewResolver;
resolver.setToolboxConfigLocation(getToolboxConfigLocation());
resolver.setDateToolAttribute(getDateToolAttribute());
resolver.setNumberToolAttribute(getNumberToolAttribute());
}
示例4: applyToViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Override
public void applyToViewResolver(Object viewResolver) {
super.applyToViewResolver(viewResolver);
VelocityViewResolver resolver = (VelocityViewResolver) viewResolver;
resolver.setToolboxConfigLocation(getToolboxConfigLocation());
resolver.setDateToolAttribute(getDateToolAttribute());
resolver.setNumberToolAttribute(getNumberToolAttribute());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:VelocityProperties.java
示例5: allowSessionOverride
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Test
public void allowSessionOverride() {
registerAndRefreshContext("spring.velocity.allow-session-override:true");
AbstractTemplateViewResolver viewResolver = this.context
.getBean(VelocityViewResolver.class);
assertThat(viewResolver).extracting("allowSessionOverride").containsExactly(true);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:VelocityAutoConfigurationTests.java
示例6: render
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
private MockHttpServletResponse render(String viewName) throws Exception {
VelocityViewResolver resolver = this.context.getBean(VelocityViewResolver.class);
View view = resolver.resolveViewName(viewName, Locale.UK);
assertThat(view).isNotNull();
HttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
this.context);
MockHttpServletResponse response = new MockHttpServletResponse();
view.render(null, request, response);
return response;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:VelocityAutoConfigurationTests.java
示例7: allowSessionOverride
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Test
public void allowSessionOverride() {
registerAndRefreshContext("spring.velocity.allow-session-override:true");
AbstractTemplateViewResolver viewResolver = this.context
.getBean(VelocityViewResolver.class);
assertThat((Boolean) ReflectionTestUtils.getField(viewResolver,
"allowSessionOverride"), is(true));
}
示例8: render
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
private MockHttpServletResponse render(String viewName) throws Exception {
VelocityViewResolver resolver = this.context.getBean(VelocityViewResolver.class);
View view = resolver.resolveViewName(viewName, Locale.UK);
assertThat(view, notNullValue());
HttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
this.context);
MockHttpServletResponse response = new MockHttpServletResponse();
view.render(null, request, response);
return response;
}
示例9: velocityViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
/**
* actual resolver for the html files
*
* @return
*/
@Bean
public VelocityViewResolver velocityViewResolver()
{
VelocityViewResolver vvw = new VelocityViewResolver();
vvw.setPrefix( "" );
vvw.setSuffix( ".html" );
// TODO in production we might actuall enable caching
vvw.setCache( false );
vvw.setExposeSpringMacroHelpers( true );
return vvw;
}
示例10: velocityViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@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;
}
示例11: velocityViewResolver
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Bean
public ViewResolver velocityViewResolver() {
VelocityViewResolver viewResolver = new VelocityViewResolver();
viewResolver.setSuffix(".vm");
viewResolver.setExposeSpringMacroHelpers(true);
viewResolver.setOrder(1);
viewResolver.setContentType("text/html; charset=UTF-8");
return viewResolver;
}
示例12: VelocityRegistration
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
private VelocityRegistration() {
super(new VelocityViewResolver());
getViewResolver().setSuffix(".vm");
}
示例13: velocity
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Test
public void velocity() {
this.registry.velocity().prefix("/").suffix(".vm").cache(true);
VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
checkPropertyValues(resolver, "prefix", "/", "suffix", ".vm", "cacheLimit", 1024);
}
示例14: velocityDefaultValues
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Test
public void velocityDefaultValues() {
this.registry.velocity();
VelocityViewResolver resolver = checkAndGetResolver(VelocityViewResolver.class);
checkPropertyValues(resolver, "prefix", "", "suffix", ".vm");
}
示例15: defaultConfiguration
import org.springframework.web.servlet.view.velocity.VelocityViewResolver; //导入依赖的package包/类
@Test
public void defaultConfiguration() {
registerAndRefreshContext();
assertThat(this.context.getBean(VelocityViewResolver.class)).isNotNull();
assertThat(this.context.getBean(VelocityConfigurer.class)).isNotNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:VelocityAutoConfigurationTests.java