当前位置: 首页>>代码示例>>Java>>正文


Java ThymeleafViewResolver类代码示例

本文整理汇总了Java中org.thymeleaf.spring4.view.ThymeleafViewResolver的典型用法代码示例。如果您正苦于以下问题:Java ThymeleafViewResolver类的具体用法?Java ThymeleafViewResolver怎么用?Java ThymeleafViewResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ThymeleafViewResolver类属于org.thymeleaf.spring4.view包,在下文中一共展示了ThymeleafViewResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: thymeleafViewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
public ThymeleafViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver resolver = new ThymeleafViewResolver();
	configureTemplateEngine(resolver, this.templateEngine);
	resolver.setCharacterEncoding(this.properties.getEncoding().name());
	resolver.setContentType(appendCharset(this.properties.getContentType(),
			resolver.getCharacterEncoding()));
	resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
	resolver.setViewNames(this.properties.getViewNames());
	// This resolver acts as a fallback resolver (e.g. like a
	// InternalResourceViewResolver) so it needs to have low precedence
	resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
	resolver.setCache(this.properties.isCache());
	return resolver;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:AbstractThymeleafViewResolverConfiguration.java

示例2: overrideCharacterEncoding

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test
public void overrideCharacterEncoding() throws Exception {
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.thymeleaf.encoding:UTF-16");
	this.context.register(ThymeleafAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	this.context.getBean(TemplateEngine.class).initialize();
	ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
	assertThat(resolver instanceof TemplateResolver).isTrue();
	assertThat(((TemplateResolver) resolver).getCharacterEncoding())
			.isEqualTo("UTF-16");
	ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
	assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
	assertThat(views.getContentType()).isEqualTo("text/html;charset=UTF-16");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ThymeleafAutoConfigurationTests.java

示例3: createLayoutFromConfigClass

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test
public void createLayoutFromConfigClass() throws Exception {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.register(ThymeleafAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	MockServletContext servletContext = new MockServletContext();
	context.setServletContext(servletContext);
	context.refresh();
	ThymeleafView view = (ThymeleafView) context.getBean(ThymeleafViewResolver.class)
			.resolveViewName("view", Locale.UK);
	MockHttpServletResponse response = new MockHttpServletResponse();
	MockHttpServletRequest request = new MockHttpServletRequest();
	request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
	view.render(Collections.singletonMap("foo", "bar"), request, response);
	String result = response.getContentAsString();
	assertThat(result).contains("<title>Content</title>");
	assertThat(result).contains("<span>bar</span>");
	context.close();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:ThymeleafAutoConfigurationTests.java

示例4: thymeleafViewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
public ThymeleafViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver resolver = new ThymeleafViewResolver();
	resolver.setTemplateEngine(this.templateEngine);
	resolver.setCharacterEncoding(this.properties.getEncoding().name());
	resolver.setContentType(appendCharset(this.properties.getContentType(),
			resolver.getCharacterEncoding()));
	resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
	resolver.setViewNames(this.properties.getViewNames());
	// This resolver acts as a fallback resolver (e.g. like a
	// InternalResourceViewResolver) so it needs to have low precedence
	resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
	resolver.setCache(this.properties.isCache());
	return resolver;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:ThymeleafAutoConfiguration.java

示例5: deviceDelegatingThymeleafViewResolverEnabled

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:true");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	ThymeleafViewResolver thymeleafViewResolver = this.context
			.getBean(ThymeleafViewResolver.class);
	AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingViewResolver",
					AbstractDeviceDelegatingViewResolver.class);
	assertThat(thymeleafViewResolver).isNotNull();
	assertThat(deviceDelegatingViewResolver).isNotNull();
	assertThat(deviceDelegatingViewResolver.getViewResolver())
			.isInstanceOf(ThymeleafViewResolver.class);
	assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
	assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
	assertThat(deviceDelegatingViewResolver.getOrder())
			.isEqualTo(thymeleafViewResolver.getOrder() - 1);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:26,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例6: deviceDelegatingThymeleafViewResolverDisabled

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(InternalResourceViewResolver.class)).isNotNull();
	assertThat(this.context.getBean(ThymeleafViewResolver.class)).isNotNull();
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例7: thymeleafViewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
public ThymeleafViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver resolver = new ThymeleafViewResolver();
	resolver.setTemplateEngine(this.templateEngine);
	resolver.setCharacterEncoding(this.properties.getEncoding().name());
	resolver.setContentType(appendCharset(this.properties.getContentType(),
			resolver.getCharacterEncoding()));
	resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
	resolver.setViewNames(this.properties.getViewNames());
	// This resolver acts as a fallback resolver (e.g. like a
	// InternalResourceViewResolver) so it needs to have low precedence
	resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
	return resolver;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:ThymeleafAutoConfiguration.java

示例8: deviceDelegatingInternalResourceViewResolverDisabled

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingInternalResourceViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	try {
		this.context.getBean(ThymeleafViewResolver.class);
	}
	catch (NoSuchBeanDefinitionException ex) {
		// expected. ThymeleafViewResolver shouldn't be defined.
	}
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例9: deviceDelegatingThymeleafViewResolverEnabled

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test
public void deviceDelegatingThymeleafViewResolverEnabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:true");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	ThymeleafViewResolver thymeleafViewResolver = this.context
			.getBean(ThymeleafViewResolver.class);
	AbstractDeviceDelegatingViewResolver deviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingViewResolver",
					AbstractDeviceDelegatingViewResolver.class);
	assertNotNull(thymeleafViewResolver);
	assertNotNull(deviceDelegatingViewResolver);
	assertTrue(deviceDelegatingViewResolver
			.getViewResolver() instanceof ThymeleafViewResolver);
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
	assertTrue(deviceDelegatingViewResolver
			.getOrder() == thymeleafViewResolver.getOrder() - 1);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:26,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例10: deviceDelegatingThymeleafViewResolverDisabled

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test(expected = NoSuchBeanDefinitionException.class)
public void deviceDelegatingThymeleafViewResolverDisabled() throws Exception {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.mobile.devicedelegatingviewresolver.enabled:false");
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			ThymeleafAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(InternalResourceViewResolver.class));
	assertNotNull(this.context.getBean(ThymeleafViewResolver.class));
	this.context.getBean("deviceDelegatingViewResolver",
			AbstractDeviceDelegatingViewResolver.class);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:DeviceDelegatingViewResolverAutoConfigurationTests.java

示例11: createLayoutFromConfigClass

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Test
public void createLayoutFromConfigClass() throws Exception {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.register(ThymeleafAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	MockServletContext servletContext = new MockServletContext();
	context.setServletContext(servletContext);
	context.refresh();
	ThymeleafView view = (ThymeleafView) context.getBean(ThymeleafViewResolver.class)
			.resolveViewName("view", Locale.UK);
	MockHttpServletResponse response = new MockHttpServletResponse();
	MockHttpServletRequest request = new MockHttpServletRequest();
	request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
	view.render(Collections.singletonMap("foo", "bar"), request, response);
	String result = response.getContentAsString();
	assertTrue("Wrong result: " + result, result.contains("<title>Content</title>"));
	assertTrue("Wrong result: " + result, result.contains("<span>bar</span>"));
	context.close();
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:ThymeleafAutoConfigurationTests.java

示例12: thymeleafViewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
public ThymeleafViewResolver thymeleafViewResolver()
{
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine());
    resolver.setOrder(1);
    resolver.setCharacterEncoding("UTF-8");
    return resolver;
}
 
开发者ID:scrumtracker,项目名称:scrumtracker2017,代码行数:10,代码来源:ThymeleafConfig.java

示例13: viewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
public ViewResolver viewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine());
    resolver.setCharacterEncoding("UTF-8");
    resolver.setOrder(1);
    return resolver;
}
 
开发者ID:ArturWisniewski,项目名称:ToDoApp-Spring,代码行数:9,代码来源:ThymeleafConfig.java

示例14: viewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
@Bean
public ViewResolver viewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine());
    resolver.setCharacterEncoding("UTF-8");
    return resolver;
}
 
开发者ID:linkedin,项目名称:custom-gradle-plugin-portal,代码行数:8,代码来源:ResourceConfig.java

示例15: getViewResolver

import org.thymeleaf.spring4.view.ThymeleafViewResolver; //导入依赖的package包/类
/**
 * Bean to configure thymeleaf view resolver
 *
 * @return the thymeleaf view resolver
 */
@Bean(name = "viewResolver")
public ThymeleafViewResolver getViewResolver() {
    final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
    viewResolver.setTemplateEngine(getTemplateEngine());
    return viewResolver;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:12,代码来源:TemplateConfig.java


注:本文中的org.thymeleaf.spring4.view.ThymeleafViewResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。