在被@Configuration注解的类中进行一下freemarker的配置,如下: import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import org.springframework.web.servlet.view.freemarker.FreeMarkerView; import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; @Bean public FreeMarkerViewResolver freeMarkerViewResolver() { FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver(); freeMarkerViewResolver.setViewClass(FreeMarkerView.class); freeMarkerViewResolver.setContentType("text/html; charset=utf-8"); freeMarkerViewResolver.setCache(true); freeMarkerViewResolver.setSuffix(".ftl"); freeMarkerViewResolver.setOrder(0); return freeMarkerViewResolver; } @Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/"); //报错点1 freeMarkerConfigurer.setDefaultEncoding("UTF-8"); //报错点2 return freeMarkerConfigurer; } 在报错点1和报错点2,提示: 我这是在maven项目中,所需要的包全部已经依赖。 求解怎么解决。我使用的是Java类来配置Spring容器,没有使用xml |
|
30分 |
看不懂!
|