SpringBoot静态资源处理

1.在SpringBoot中,通过以下方式处理静态资源:

  • webjars    localhost:8080/webjars
  • classpath:public,static,/**,resources   localhost:8080/

优先级:resources>static>public


2.模板引擎

只需要使用thymeleaf,导入相关依赖,将相关资源放入templates包下即可

1 public static final String DEFAULT_PREFIX = “classpath:/templates/”;
2 public static final String DEFAULT_SUFFIX=".html";

 


3.首页配置:静态资源都用thymeleaf进行管理;@{}


4.页面国际化:

  • 配置i18n
  • 想要自动切换语言,需要自定义组件LocaleResolver
  • 将组件配置到容器中@Bean

原文地址:https://www.cnblogs.com/zqzhen/p/12547112.html