Java Code Examples for org.thymeleaf.spring5.view.ThymeleafViewResolver#setContentType()

The following examples show how to use org.thymeleaf.spring5.view.ThymeleafViewResolver#setContentType() . 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: WallRideThymeleafConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver(SpringTemplateEngine templateEngine) {
	ThymeleafViewResolver viewResolver = new ExtendedThymeleafViewResolver();
	viewResolver.setTemplateEngine(templateEngine);
	viewResolver.setViewNames(this.thymeleafProperties.getViewNames());
	viewResolver.setCharacterEncoding(this.thymeleafProperties.getEncoding().name());
	viewResolver.setContentType(this.thymeleafProperties.getServlet().getContentType() + ";charset=" + this.thymeleafProperties.getEncoding());
	viewResolver.setCache(false);
	viewResolver.setOrder(2);
	return viewResolver;
}
 
Example 2
Source File: WebAdminConfiguration.java    From wallride with Apache License 2.0 5 votes vote down vote up
@Bean
public ThymeleafViewResolver thymeleafViewResolver() {
	ThymeleafViewResolver viewResolver = new ExtendedThymeleafViewResolver();
	viewResolver.setTemplateEngine(templateEngine());
	viewResolver.setViewNames(this.properties.getViewNames());
	viewResolver.setCharacterEncoding(this.properties.getEncoding().name());
	viewResolver.setContentType(this.properties.getServlet().getContentType() + ";charset=" + this.properties.getEncoding());
	viewResolver.setCache(false);
	viewResolver.setOrder(1);
	return viewResolver;
}
 
Example 3
Source File: WebMVCConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver htmlViewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine(htmlTemplateResolver()));
    resolver.setContentType("text/html");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setViewNames(ArrayUtil.array("*.html"));
    return resolver;
}
 
Example 4
Source File: WebMVCConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver javascriptViewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine(javascriptTemplateResolver()));
    resolver.setContentType("application/javascript");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setViewNames(ArrayUtil.array("*.js"));
    return resolver;
}
 
Example 5
Source File: WebMVCConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public ViewResolver plainViewResolver() {
    ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setTemplateEngine(templateEngine(plainTemplateResolver()));
    resolver.setContentType("text/plain");
    resolver.setCharacterEncoding("UTF-8");
    resolver.setViewNames(ArrayUtil.array("*.txt"));
    return resolver;
}