2017-08-16 96 views
1

我們使用的是Spring MVC框架,並且在我們店面上點擊按鈕時有一個按鈕,我們很少在控制檯上收到以下錯誤。有什麼辦法可以阻止http處理未知方法?

INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | Jun 28, 2017 1:08:03 PM org.apache.catalina.core.StandardWrapperValve invoke 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | SEVERE: Servlet.service() for servlet [DispatcherServlet] in context with path [] threw exception [Error while processing internal filterchain. Exception occurred at chain position: 8 of 11. Current filter: 'FilterChainProxy[Filter Chains: [[ Ant [pattern='/_ui/**'], []], [ Ant [pattern='/steeldeals/**'], []], [ Ant [pattern='/checkout/**'], [org.spri[email protected]6ccd9b91, org.spring[email protected]2ea08465, org.springframework.secu[email protected]2c541acd, org.[email protected]45ab9f77, org.springframework.s[email protected]672615d, org.sp[email protected]3f5623f9, org.springframework.[email protected]3053d0eb, org.springfram[email protected]4eb90d16, o[email protected]570a47ba, org[email protected]63eb30fa, org.springfr[email protected]65dca055]], [ [email protected], [org.spri[email protected]ffa7b85, org.spring[email protected]5c360f5, org.springframework.secu[email protected]5e1277c7, org.[email protected]e75da11, org.springframework.s[email protected]5b3f9981, org.sp[email protected]2c7712f4, org.springframework.[email protected]3d7d67fa, org.springframework.securi[email protected]74356d9f, org.springframework.security.web.authentication.AnonymousAuthenticatio[email protected], o[email protected]23556539, org[email protected]3b68934e, org.springfr[email protected]4e9f045a]]]]'!; nested exception is java.lang.IllegalArgumentException: No enum constant org.springframework.http.HttpMethod.PROPFIND] with root cause 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | java.lang.IllegalArgumentException: No enum constant org.springframework.http.HttpMethod.PROPFIND 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at java.lang.Enum.valueOf(Enum.java:236) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.http.HttpMethod.valueOf(HttpMethod.java:27) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.util.matcher.AntPathRequestMatcher.matches(AntPathRequestMatcher.java:125) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource.getAttributes(DefaultFilterInvocationSecurityMetadataSource.java:86) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:130) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
INFO | jvm 1 | main | 2017/06/28 13:08:03.644 | at de.hybris.platform.servicelayer.web.AbstractPlatformFilterChain$InternalFilterChain.doFilter(AbstractPlatformFilterChain.java:226) 

我們用下面的代碼片段在春季安全-config.xml中

<security:http pattern="/_ui/**" security="none"/> 
<security:http pattern="/SteelDeals/**" security="none"/> 

<!-- Security config for checkout - it has its own login page --> 
<security:http disable-url-rewriting="true" pattern="/checkout/**" use-expressions="true"> 
    <security:anonymous username="anonymous" granted-authority="ROLE_ANONYMOUS" /> 
    <security:session-management session-authentication-strategy-ref="fixation" /> 

    <!--<security:session-management session-fixation-protection="none" />--> 

    <!-- SSL/AUTHENTICATED pages --> 
    <security:intercept-url pattern="/checkout/j_spring_security_check" requires-channel="https"/> 
    <security:intercept-url pattern="/checkout*" requires-channel="https"/> 
    <security:intercept-url pattern="/checkout/**" requires-channel="https"/> 
+1

代碼和配置 –

+3

不清楚你想要什麼。服務器已經不處理'PROPFIND'方法,因爲如果失敗並出現「未知方法」錯誤。對未知方法還應該做些什麼? – Andreas

+0

將其添加到問題以便對其進行格式化 –

回答

0

您可以配置的DispatcherServlet只派遣你要處理的方法。但是,您無法處理不存在的HTTP方法。

0

您的代碼已經拒絕了錯誤的方法,您收到此錯誤意味着您的客戶端代碼(訪問您的控制器的代碼,例如ui代碼)存在一些問題。

但是,如果你要定義你的控制器網址的具體方法,你可以通過使用@RequestMapping註釋method財產

@RequestMapping(value = "/bucket", method = {RequestMethod.GET}) 
public Collection<BucketResponse> getBucket() { 
    return service.getBucket(); 
} 
相關問題