@RequestMapping( value = {"/{user_name}/update"}, method = {RequestMethod.POST} ) public void update(@Validated UserInfo userInfo, BindingResult br, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { String message = ""; boolean success = false; if (br.hasErrors()) { message = "输入的信息有错误!"; this.writeJsonResponse(response, success, message); } else { String userPhotoFileName = this.handlePhotoUpload(request, "userPhotoFile"); if (!userPhotoFileName.equals("upload/NoImage.jpg")) { userInfo.setUserPhoto(userPhotoFileName); } String jianliFileFileName = this.handleFileUpload(request, "jianliFileFile"); if (!jianliFileFileName.equals("")) { userInfo.setJianliFile(jianliFileFileName); } String smrzzlFileName = this.handleFileUpload(request, "smrzzlFile"); if (!smrzzlFileName.equals("")) { userInfo.setSmrzzl(smrzzlFileName); } try { this.userInfoService.updateUserInfo(userInfo); message = "用户更新成功!"; success = true; this.writeJsonResponse(response, success, message); } catch (Exception var12) { var12.printStackTrace(); message = "用户更新失败!"; this.writeJsonResponse(response, success, message); } } }
时间: 2023-06-25 13:07:51 浏览: 52
这段代码是一个使用Spring MVC框架编写的Java Web应用程序中的一个请求映射方法。该方法用于处理POST请求,路径为/{user_name}/update。它接收一个类型为UserInfo的对象,使用@Validated注解进行校验,如果校验失败则返回错误信息。如果校验成功,则使用HttpServletRequest对象处理上传的用户头像、简历文件、实名认证资料,并将更新后的用户信息保存到数据库中。最后,该方法返回一个JSON格式的响应,其中包含一个布尔类型的success和一个字符串类型的message,表示操作结果和操作信息。如果操作成功,则success为true,message为"用户更新成功!",否则为false和"用户更新失败!"。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)