我将此配置用于我的网络配置
@Configuration
@ComponentScan("com.siarhei")
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("/");
}
@Bean
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
multipartResolver.setMaxUploadSize(5000000);
return multipartResolver;
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(jsonConverter());
}
@Bean(name = "jacksonHttpMessageConverter")
public MappingJackson2HttpMessageConverter jsonConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setPrettyPrint(true);
converter.setSupportedMediaTypes(Arrays.asList(MediaType.valueOf("application/json")));
return converter;
}
并且它有效但现在我发现了关于百里香的标准配置,这是
@Configuration
@ComponentScan("com.valentine")
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
@Bean
public ServletContextTemplateResolver templateResolver (){
ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
resolver.setPrefix("/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
return resolver;
}
@Bean
public SpringTemplateEngine templateEngine (){
Set<IDialect> dialects = new HashSet<>();
dialects.add(new LayoutDialect());
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setTemplateResolver(templateResolver());
engine.setAdditionalDialects(dialects);
return engine;
}
@Bean
public ThymeleafViewResolver viewResolver(){
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
resolver.setOrder(1);
resolver.setViewNames(new String[]{"," , "js/*" , "template/*"});
return resolver;
}
这不起作用。
我正在使用百里香,我的问题为什么其他配置对百里香叶有效,这不起作用?