日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring boot 默认静态资源路径与手动配置访问路径的方法

發(fā)布時間:2023/12/20 javascript 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。