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。我瀏覽過互聯網和堆棧溢出,但仍無法解決此問題。
難道這是因爲你的請求是頂層路徑上的映射嗎?「/ wha',而你的攔截器模式排除在子路徑上?」/ **/wha/**「?你試過排除'」/ wha/**「'? –
@DJ。我試過'/ wha/**',但是這也沒有奏效 – Navio53
''/ **/wha」'? –