Spring 验证忽略规则
当我通过curl -X PUT -F "new_name=t" http://localhost:8080/category/rename/26 ping这个端点时,我在端点端进行了验证
@PutMapping("/rename/{id}")
public void renameCategoryByName(@PathVariable long id, @RequestParam @Size(min = 2, max = 20) @Valid String new_name) {
categoryService.renameCategoryById(id, new_name);
}
,我没有收到错误并且方法更改了名称实体。
我使用此依赖项进行验证:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
i have validation in endpoint
@PutMapping("/rename/{id}")
public void renameCategoryByName(@PathVariable long id, @RequestParam @Size(min = 2, max = 20) @Valid String new_name) {
categoryService.renameCategoryById(id, new_name);
}
end when i ping this end point by curl -X PUT -F "new_name=t" http://localhost:8080/category/rename/26, i don't get error and method change the name of entity.
I use this dependency to validation:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论