當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring boot 默认静态资源路径与手动配置访问路径的方法
生活随笔
收集整理的這篇文章主要介紹了
Spring boot 默认静态资源路径与手动配置访问路径的方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
這篇文章主要介紹了Spring boot 默認(rèn)靜態(tài)資源路徑與手動配置訪問路徑的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
在application.propertis中配置
##端口號 server.port=8081 ##默認(rèn)前綴 spring.mvc.view.prefix=/ ## 響應(yīng)頁面默認(rèn)后綴 spring.mvc.view.suffix=.html # 默認(rèn)值為 /** spring.mvc.static-path-pattern=/** # 這里設(shè)置要指向的路徑,多個使用英文逗號隔開,默認(rèn)值為 classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ spring.resources.static-locations= classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/****/如果自定義訪問路徑則需要添加WebConfig配置類
package com.dakewang.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /*** 手動配置靜態(tài)資源路徑* */ @Configuration public class WebConfig extends WebMvcConfigurerAdapter{@Overridepublic void configurePathMatch(PathMatchConfigurer configurer) {configurer.setUseSuffixPatternMatch(false).setUseTrailingSlashMatch(true);} }在controller中
/*** 跳轉(zhuǎn)index.html頁面* @return*/ @RequestMapping("/index") public String indexHtml() {return "index"; }在瀏覽器中訪問地址
localhost:8081/index
轉(zhuǎn)載于:https://www.cnblogs.com/wlsblog/p/8046015.html
總結(jié)
以上是生活随笔為你收集整理的Spring boot 默认静态资源路径与手动配置访问路径的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 韩研究人员声称:创造出了一块“不可破坏”
- 下一篇: 一篇文章彻底说清JS的深拷贝/浅拷贝