我正在使用spring引导。我想验证POST请求参数。所以我通过@Validated注释获得了良好的效果,但是这需要为每个API创建一个不同的类。我应该如何编写我的代码?POST/GET请求在Spring Boot中的参数验证
至于例如,这是我的API
@RequestMapping("/tags/{tagId}/{tagParentId}")
public Response<Demo> a(@PathVariable int tagId, @PathVariable int tagParentId){
... code
}
@RequestMapping("/data/{courseId}/{instId}")
public Response<Demo> b(@PathVariable int courseId, @PathVariable int instId){
... code
}
我应该如何改变我的代码添加PARAMS验证因为有API的这样的,我并不需要创建两个不同的验证类?只需一个类,然后我可以为不同的API添加不同的功能。