[問題] 關於Spring trailing slash問題

看板java作者時間7年前 (2017/11/20 23:39), 7年前編輯推噓0(005)
留言5則, 2人參與, 7年前最新討論串1/2 (看更多)
Spring default是enable Trailing Slash的行為 我在我的configure有註冊RequestMappingHandlerMapping這個bean 並且取消TrailingSlashMatch的使用,如下: @Bean public RequestMappingHandlerMapping equestMappingHandlerMapping() { RequestMappingHandlerMapping rmhm = new RequestMappingHandlerM ap rmhm.setUseSuffixPatternMatch(false); rmhm.setUseTrailingSlashMatch(false ); return rmhm; } 但是很奇怪的, 我的controller有一個method @RequestMapping("/service"), URL打上/service/還是可以...似乎上面那段的設定無效 我的Spring MVC dependency version是5.0.0.RELEASE 不知有沒有人也遇到這狀況? 感謝各位! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.135.236.53 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1511192380.A.AC5.html ※ 編輯: tony21177 (220.135.236.53), 11/20/2017 23:41:34 ※ 編輯: tony21177 (220.135.236.53), 11/21/2017 08:16:34

11/21 08:33, 7年前 , 1F
setUseTrailingSlashMatch(true) ← true不就是要用?
11/21 08:33, 1F

11/21 08:33, 7年前 , 2F
不用是要用false吧
11/21 08:33, 2F
※ 編輯: tony21177 (42.73.148.153), 11/21/2017 11:39:05

11/21 11:40, 7年前 , 3F
打錯,是false,不管我用true或false都是啟用的...
11/21 11:40, 3F

11/21 11:41, 7年前 , 4F
我在Udemy上看到相同提問,但助教也不知為什麼,上網也
11/21 11:41, 4F

11/21 11:41, 7年前 , 5F
沒有找到一樣的問題..
11/21 11:41, 5F
文章代碼(AID): #1Q4lSyh5 (java)
文章代碼(AID): #1Q4lSyh5 (java)