Spring MVC 3->验证

Spring MVC 3->验证,第1张

Spring MVC 3->验证

我做到了在此示例中显示的内容:http : //blog.springsource.com/2010/01/25/ajax-
simplifications-in-spring-3-0/

@RequestMapping(method=RequestMethod.POST)public @ResponseBody Map<String, ? extends Object> create(@RequestBody Account account, HttpServletResponse response) {    Set<ConstraintViolation<Account>> failures = validator.validate(account);    if (!failures.isEmpty()) {        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);        return validationMessages(failures);    } else {        accounts.put(account.assignId(), account);        return Collections.singletonMap("id", account.getId());    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5621916.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存