[英]How do I match this url pattern in filter
給出以下代碼:
@RequestMapping(path = "/run/{alias}/synchronous")
public String start(@PathVariable String test) {
return "ok";
}
我想匹配requestmapping方法中的網址。 我嘗試了這個沒有成功。
registration.addUrlPatterns("/run/*/synchronous");
我使用這些代碼來處理GET和POST方法。
@GetMapping("/run/{alias}/synchronous")
@PostMapping("/run/{alias}/synchronous")
你有嘗試過嗎? 將一些“鍵”添加到@PathVariable,因為變量“測試”與“別名”不同。 檢查此鏈接請求在Baeldung中映射
@RequestMapping(path = "/run/{alias}/synchronous")
public String start(@PathVariable("alias") String test){
return "ok";
}
據我所知,servlet規范在字符串中間不允許使用通配符。 我正在尋找與您相同的答案...用於調用FilterRegistrationBean.addUrlPatterns()。 我正在研究如何制作自己的使用正則表達式或endsWith的Filter。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.