@RestController
@RequestMapping("/api")
public class AbcController {
@RequestMapping(value = "/abc", method = RequestMethod.GET)
public String abc(){
return "Hello";
}
}
有效的URL:http://localhost:8080/api/abc
无效的URLs:
http://localhost:8080////api/abc
http://localhost:8080/////api////abc
http://localhost:8080/////////api/////abc
问题:我的控制器接受所有上述URL。我想限制它,只接受有效的URL,并在无效的URL上抛出错误。
注意:我没有使用任何自定义路由。这是默认的Spring路由。