2016-06-21 38 views
0

我有一個控制器類:excludePathPatterns不工作 - 春

import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.web.bind.annotation.*; 

import java.util.Map; 

@RestController 
@RequestMapping("/wha") 
public class Controlla { 

    @RequestMapping(method= RequestMethod.POST) 
    public @ResponseBody Map<String, Object> hollow(@RequestBody Map<String, Object> body) { 
     return body; 
    } 
} 

和攔截請求的攔截器類。這是我如何添加攔截器:

@Bean 
public Interc inter() { 
    return new Interc(); 
} 

@Override 
public void addInterceptors(InterceptorRegistry registry) { 
    registry.addInterceptor(inter()) 
      .addPathPatterns("/**") 
      .excludePathPatterns("/**/wha/**"); 
} 

請求不會得到截獲,但它就像excludePathPatterns甚至不存在。它不起作用。我正在運行Spring版本4.2.4.RELEASE。我瀏覽過互聯網和堆棧溢出,但仍無法解決此問題。

+0

難道這是因爲你的請求是頂層路徑上的映射嗎?「/ wha',而你的攔截器模式排除在子路徑上?」/ **/wha/**「?你試過排除'」/ wha/**「'? –

+0

@DJ。我試過'/ wha/**',但是這也沒有奏效 – Navio53

+0

''/ **/wha」'? –

回答

0

完成系統重新啓動後,關閉並重新打開它,一切都按預期工作。