Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在springmvc中制作post_Java_Spring_Spring Mvc - Fatal编程技术网

Java 如何在springmvc中制作post

Java 如何在springmvc中制作post,java,spring,spring-mvc,Java,Spring,Spring Mvc,在我的方法中如何做回帖认证。? 我喜欢发布以进行身份验证(SpringMVC中默认的方法用于身份验证),并在添加验证之前确认用户是否处于活动状态 @RequestMapping(value = "/signin", method = RequestMethod.POST) public ModelAndView authenticates( @RequestParam("username") String login, @RequestParam("passwor

在我的方法中如何做回帖认证。? 我喜欢发布以进行身份验证(SpringMVC中默认的方法用于身份验证),并在添加验证之前确认用户是否处于活动状态

@RequestMapping(value = "/signin", method = RequestMethod.POST)
public ModelAndView authenticates(
        @RequestParam("username") String login,
        @RequestParam("password") String password,
        @RequestParam("_spring_security_remember_me") String remember,
        @RequestParam("_csrf") String csrf,
        RedirectAttributes ra
        ) throws Exception {

    ModelAndView model = new ModelAndView();
    Account account = accountService.findByLogin(login);


    if (!account.isActive()) {  
        MessageHelper.addErrorAttribute(ra, "signin.errorUserDown", login, login);
        model.setViewName("redirect:/signin");
        return model;
        //return "redirect:/signin";
    }


    //userService.loadUserByUsername(login);
    //userService.signin(account);


    //model.addObject("submit");
    model.addObject("username", login);
    model.addObject("password", password);
    model.addObject("_spring_security_remember_me", remember);
    model.addObject("_csrf", csrf);
    model.setViewName("signin/signinValidate");

    return model;
    //return "authenticate";
}
我想换一种方式

在html中:

<span th:text="${session['SPRING_SECURITY_LAST_EXCEPTION'].message}"></span>
最后,i18n的个性信息:

    <!--/* Show general error message when form contains errors */-->
    <th:block th:if="${param.error != null}">
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('Bad credentials')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorBadCredentials})">Alert</div>
        </th:block>
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('User is disabled')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorUserDisabled})">Alert</div>
        </th:block>
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('User account is locked')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorUserLocked})">Alert</div>
        </th:block>
    </th:block>

警觉的
警觉的
警觉的

当用户成功登录时,您希望看到什么?你能告诉我这种行为吗?当用户成功重定向到被查询的页面时。我也有userDetail.setEnable=account.isActive(),但当我查询html中的SPRING\u SECURITY\u LAST\u EXCEPTION时,这是空的,为什么?
    <!--/* Show general error message when form contains errors */-->
    <th:block th:if="${param.error != null}">
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('Bad credentials')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorBadCredentials})">Alert</div>
        </th:block>
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('User is disabled')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorUserDisabled})">Alert</div>
        </th:block>
        <th:block th:if="${session['SPRING_SECURITY_LAST_EXCEPTION'].message.contains('User account is locked')}">
            <div th:replace="fragments/alert :: alert (type='danger', message=#{signin.errorUserLocked})">Alert</div>
        </th:block>
    </th:block>