如何将bindingResult对象传递给Spring中的另一个请求URI

时间:2017-06-01 08:08:44

标签: java spring-mvc spring-boot

在PRINT_LOGIN中,请求URI绑定到bindingResult对象的错误,我需要将其传递给另一个请求URI(VERIFY_ACCOUNT),我可以检查错误并执行我的操作

@RequestMapping(PRINT_LOGIN)
public String printLogin(Map<String, Object> model, @Valid PrintLoginForm printLoginForm, 
    BindingResult bindingResult, HttpServletRequest request) throws IOException {
    String accountNum = printLoginForm.getAccountNumber();
    String zipCode = printLoginForm.getZipCode();
    if (StringUtils.isNotBlank(accountNum) && StringUtils.isNotBlank(zipCode)) {
        // valid
    } else { // Invalid
        bindingResult.reject("ERROR_INVALID_ACCOUNTNUMBER");
        // How to pass this bindingResult to the below URI ? 
        return createRedirectUri(VERIFY_ACCOUNT);
    }
    return VIEW_ACCOUNT_INDENTIFICATION;
}

@RequestMapping(VERIFY_ACCOUNT)
public String verifyAccount(Map<String, Object> model, HttpServletRequest request) {
    //How to get bindingResult object from the above request ? 
    return VIEW_VERIFY_ACCOUNT;
}

0 个答案:

没有答案