{"id":368,"date":"2017-06-13T17:12:01","date_gmt":"2017-06-13T09:12:01","guid":{"rendered":"http:\/\/dingqs.imwork.net\/?p=368"},"modified":"2017-06-13T17:12:01","modified_gmt":"2017-06-13T09:12:01","slug":"apache-shiro","status":"publish","type":"post","link":"https:\/\/www.dd-home.top\/?p=368","title":{"rendered":"Apache Shiro Form\u8868\u5355\u6821\u9a8c"},"content":{"rendered":"<p><!--more--><\/p>\n<p>a.\u76f4\u63a5\u8df3\u8f6c\u5230login.jsp\u65f6\u53ef\u4ee5\u4f7f\u7528GET\u65b9\u6cd5,\u4e0d\u643a\u5e26\u53c2\u6570<\/p>\n<pre class=\"\">@RequestMapping(value = \"\/login\", method = RequestMethod.GET)<\/pre>\n<p>b.form\u8868\u5355POST\u63d0\u4ea4\u9a8c\u8bc1\u7684\u65f6\u5019\u4f1a\u6709\u9a8c\u8bc1,\u8fd9\u65f6\u53ef\u4ee5\u5728POST\u4e2d\u6dfb\u52a0\u6821\u9a8c<\/p>\n<pre>@RequestMapping(value = \"\/login\", method = RequestMethod.POST)<\/pre>\n<pre class=\"\">@RequestMapping(value = \"\/login\", method = RequestMethod.GET)\npublic String loginForm(Model model) {\n   return \"\/login\";\n}\n\n@RequestMapping(value = \"\/login\", method = RequestMethod.POST)\npublic String login(Model model, @Valid @ModelAttribute(\"validatorBean\") ValidatorUser validatorBean, BindingResult result) {\n    if (result.hasErrors()) {\n        return loginForm(model);\n    }\n    String exceptionClassName = (String) request.getAttribute(\"shiroLoginFailure\");\n\n    logger.info(exceptionClassName);\n    if (CaptchaException.class.getName().equals(exceptionClassName)) {\n        result.rejectValue(\"error\", \"code.is.wrong\");\n        return loginForm(model);\n    } else if (UnknownAccountException.class.getName().equals(exceptionClassName)) {\n        result.rejectValue(\"error\", \"user.username.password.notmatch\");\n        return loginForm(model);\n    } else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {\n        result.rejectValue(\"error\", \"user.username.password.notmatch\");\n        return loginForm(model);\n    } else if (ExcessiveAttemptsException.class.getName().equals(exceptionClassName)) {\n        result.rejectValue(\"error\", \"user.locked\");\n        return loginForm(model);\n    } else if (exceptionClassName != null) {\n        result.rejectValue(\"error\", \"user.error.unknown\");\n        return loginForm(model);\n    }\n\n    return \"redirect:\/\";\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368"}],"version-history":[{"count":0,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dd-home.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}