[問題] spring security 問題

看板java作者 (罹患重度能年病的燕叔)時間10年前 (2015/05/14 10:59), 10年前編輯推噓0(007)
留言7則, 2人參與, 最新討論串1/1
大家好,目前有個狀況是 只要一開 spring security, post method 就會進不去... 以下是設定檔跟程式片段 Test.java ... @RequestMapping(value = { "/test" }, method = RequestMethod.POST) public void testPost() { System.out.println("post"); } @RequestMapping(value = { "/test" }, method = RequestMethod.GET) public void testGet(HttpServletRequest req) { System.out.println("get"); } ... spring-security.xml <http auto-config="true" use-expressions="true"> <intercept-url pattern="/test" access="permitAll" /> ... </http> web.xml <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> result 同時做了/test的post跟get method, 結果只有出現get... 2015-05-14 WARN PageNotFound:198 - Request method 'POST' not supported get ... 想請問一下這樣是否有辦法看出哪邊設定出錯? (如果spring-security.xml的permitAll改成denyAll的話,get會被擋住, 所以設定上應該沒問題才是?) 或者是說有其他的方式可以不要檢查 /test post method? 感謝 <(_ _)> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.228.38.205 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1431572357.A.805.html ※ 編輯: swallowcc (61.228.38.205), 05/14/2015 11:08:42

05/14 14:46, , 1F
解開了orz 另外開一個 <http /> 就好...
05/14 14:46, 1F

05/14 14:46, , 2F
<http pattern="/test*" security="none"/>
05/14 14:46, 2F

05/14 18:53, , 3F
如果是最新版的話 csrf防護預設是開的 POST要附_csrf
05/14 18:53, 3F

05/14 18:59, , 4F
05/14 18:59, 4F

05/14 19:01, , 5F
security="none"就沒意義了
05/14 19:01, 5F

05/14 19:59, , 6F
建議把security的log level調到debug 會看得更清楚~
05/14 19:59, 6F

05/14 21:52, , 7F
感謝,我研究看看 ^^>
05/14 21:52, 7F
文章代碼(AID): #1LL0-5W5 (java)
文章代碼(AID): #1LL0-5W5 (java)