Spring前端Controller项目替换为SpringBoot遇到的坑

页面解析不了加入如下配置:

pom:


    org.springframework.boot
    spring-boot-starter-parent
    2.0.2.RELEASE



    UTF-8
    UTF-8
    1.8
    3.0.9.RELEASE
    2.3.0

页面需要放在resources的templates目录下,其他静态文件放在resources目录下

配置文件:
#######################thymeleaf################################
server.servlet.context-path=/aiis //替换成自己的项目路径
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix= .html
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode: HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false
#######################静态资源处理################################
spring.resources.static-locations=classpath:/static/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/public/,classpath:/resources/static/
spring.mvc.static-path-pattern=/static/**
加入配置类:
@SpringBootConfiguration
public class WebMvcConfig extends WebMvcConfigurationSupport {
   public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
      super.addResourceHandlers(registry);
   }
}

 

你可能感兴趣的:(Spring前端Controller项目替换为SpringBoot遇到的坑)