当前位置: 移动技术网 > IT编程>开发语言>Java > springboot学习(2)

springboot学习(2)

2018年08月28日  | 移动技术网IT编程  | 我要评论
webmvcconfigureradapter 在springboot2.0及以上版本过时问题

webmvcconfigureradapter已经过时,替代方案:
1 实现 webmvcconfigurer 接口;
2 继承 webmvcconfigurationsupport ;

但是需要注意的是继承这个类会导致 springboot 的自动配置功能失效,所以如果还需要使用springboot的自动配置功能则推荐使用第一种方案

===================================================================================================================
模板文件中静态资源使用 thymeleaf标签问题
在模板文件中,对于如下链接:
<link href="asserts/css/bootstrap.min.css" rel="stylesheet">
建议配置成:
<link href="asserts/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.css}" rel="stylesheet">
因为使用thymeleaf标签可以动态的适配我们的服务访问路径;
比如我们修改我们的服务访问路径为:
server.servlet.context-path=/fzy
的时候,我们重新访问应用的时候需要在访问的根路径中添加/fzy才能正常方位,而这时我们html中配置的上面的link链接不需要修改就可以正常使用,框架会在url中为我们添加上
修改后的配置路径:<link href="/fzy/webjars/bootstrap/4.0.0/css/bootstrap.css" rel="stylesheet">,红色字体为框架自动识别添加的
(http://localhost:8080修改为http://localhost:8080/fzy 才能正常访问)




 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网