【发布时间】:2019-06-25 15:30:36
【问题描述】:
@RequestMapping(value="apiInventory/apis",method=RequestMethod.GET)
public Map<String,Object> getData(@NotNull @Valid @RequestParam("host") String host,
@NotNull @Valid @RequestParam("apiGroup") String basePath,
@RequestParam(value="path",required=false) String path,
@RequestParam(value="version",required=false) String version,
@Valid @Pattern(regexp="get|post|put|delete|patch|options") @RequestParam(value="httpMethod",required=false) String httpMethod,
@RequestParam(value="includeAttributeDefinition",required=false, defaultValue="false") boolean includeAttributeDefinition) throws Exception{
//My logic
}
我必须确保 httpMethod 只接受 get、post、put、delete、patch、options 的值
但是,验证没有发生。我期待一个错误,但当我发送一个无效的httpMethod 时没有抛出任何错误。我做错了什么?
【问题讨论】:
标签: java regex spring spring-boot