看板 java 關於我們 聯絡資訊
大家好,目前有個狀況是 只要一開 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
swallowcc: 解開了orz 另外開一個 <http /> 就好... 05/14 14:46
swallowcc: <http pattern="/test*" security="none"/> 05/14 14:46
yyc1217: 如果是最新版的話 csrf防護預設是開的 POST要附_csrf 05/14 18:53
yyc1217: http://goo.gl/xjDXHK 05/14 18:59
yyc1217: security="none"就沒意義了 05/14 19:01
yyc1217: 建議把security的log level調到debug 會看得更清楚~ 05/14 19:59
swallowcc: 感謝,我研究看看 ^^> 05/14 21:52