Spring + Thymeleaf + Tiles中的消息属性文件问题

时间:2014-06-20 04:28:39

标签: spring-mvc tiles thymeleaf

我的邮件属性文件的内容未正确显示。我得到的是??关键?在网页上。

以下是我的Spring Web Java配置的相关部分:

@Bean
public ServletContextTemplateResolver templateResolver() {
    ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
    resolver.setTemplateMode("HTML5");
    resolver.setCharacterEncoding("utf-8");
    resolver.setCacheable(false);
    resolver.setOrder(2);
    return resolver;
}

public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine engine = new SpringTemplateEngine();
    engine.setTemplateResolver(templateResolver());
    engine.addDialect(new TilesDialect()); // Tiles
    engine.addDialect(new SpringSecurityDialect()); // Tiles
    engine.addDialect(new ConditionalCommentsDialect()); // Tiles
    return engine;
}

   @Bean
public ViewResolver viewResolver() {

    ThymeleafViewResolver delegate = new ThymeleafViewResolver();
    delegate.setViewClass(ThymeleafTilesView.class); // Tiles
    delegate.setTemplateEngine(templateEngine());
    delegate.setCharacterEncoding("UTF-8");
    delegate.setOrder(1);
    delegate.setViewNames(new String[] { "*" });
    delegate.setCache(false); 
            return delegate;
}

@Bean
public ThymeleafTilesConfigurer thymeleafTilesConfigurer() {
    ThymeleafTilesConfigurer ttc = new ThymeleafTilesConfigurer();
    ttc.setDefinitions(new String[] { "/WEB-INF/defs/views.xml" });
    return ttc;
}

   @Bean
public MessageSource messageSource() {

    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasenames("/WEB-INF/messages/messages");
    messageSource.setUseCodeAsDefaultMessage(true);
    messageSource.setDefaultEncoding("UTF-8");      
    messageSource.setCacheSeconds(0);
    return messageSource;
}

在对Thymeleaf教程(http://xpadro.blogspot.ca/2014/02/thymeleaf-integration-with-spring-part-1.html)的配置进行比较时,唯一的区别是Tiles相关配置。上面的配置有什么问题?

0 个答案:

没有答案