HttpServletRequest 统一校验
时间: 2023-09-25 16:12:27 浏览: 88
HttpServletRequestS
HttpServletRequest 统一校验是通过在方法参数上添加注解实现的。在引用中的代码示例中,通过在@RequestParam注解中添加@NotBlank(message = "编号不允许为空")注解,可以对code参数进行非空校验。同样地,在引用中的代码示例中,通过在@RequestParam注解中添加@NotBlank(message = "昵称不允许为空")注解,可以对name参数进行非空校验。这样,在接收到请求时,如果对应的参数为空,会返回相应的错误信息。这种方式可以统一进行参数校验,避免重复的校验逻辑代码,提高了代码的可维护性和可读性。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [如何HttpServletRequest文件对象并储存](https://download.csdn.net/download/weixin_38735887/12924092)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Controller层接口参数校验统一处理](https://blog.csdn.net/weixin_39708557/article/details/114601173)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文