本文整理匯總了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}