如何在弹簧控制器方法之间发送参数

时间:2014-10-29 20:36:38

标签: java spring spring-mvc

我有一个resetPassword.jsp表单,它发布到resetPassword方法,请求被重定向到updateNewPassword方法,如下所示

使用jdk 7和spring MVC 4

@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView resetPassword(HttpServletRequest request, HttpServletResponse response) throws IOException,
        ServletException {
    getCurrentRequestProperties().put(CurrentRequestProperties.IS_VALID_REQUEST, true);
    ModelAndView mav = new ModelAndView();
    String hStrCallback = request.getParameter("hString");
    UserSecurityQuestions qRecord;
    if (qRecord.equalsAnswer(1, ans1) && qRecord.equalsAnswer(2, ans2)) {
            RequestDispatcher rd = request.getRequestDispatcher("/updateNewPassword.do");
            rd.forward(request, response);
            mav.setViewName("updateNewPassword.do");
    }
    mav.addObject("notimeout", true);
    return mav;
}

@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView updateNewPassword(HttpServletRequest request, HttpServletResponse response) throws IOException,
        ServletException {
    getCurrentRequestProperties().put(CurrentRequestProperties.IS_VALID_REQUEST, true);
    ModelAndView mav = new ModelAndView();
    String hString = request.getParameter("hString");
     String newPassword = request.getParameter("newPassword");
    String confirmPassword = request.getParameter("confirmPassword");
    if (StringUtils.isNotEmpty(newPassword) || StringUtils.isNotEmpty(confirmPassword)) {
        UserSecurityQuestions qRecord = api.search.query(UserSecurityQuestions.class,
                api.search.property("hashString").eq(hString)).first();
        if (qRecord != null && !qRecord.isValidRequest()) {
            mav.addObject("failedMessage", "forgot.url.expired");
        } else 
        {
          // updates the password
         }
        } else {
        mav.addObject("hString", hString);
        mav.addObject("notimeout", true);
    }
    return mav;
}

步骤1:这是工作流程,当为用户重置密码时,电子邮件将作为bwlow发送 {},当用户点击URL用户时,获取带有securityQuestions的resetPassword.jsp

步骤2:一旦用户回答securityQuestions,用户就会被重定向到updatedPassword.jsp(请求在此步骤中从resetPassword方法转到updateNewPassword方法,而hString在这里是accessbile)

步骤3:当用户更新updatedPassword.jsp上的密码并提交请求时,请求转到updateNewPassword方法但是在此步骤中将hString作为null,即使我在updatedPassword中将https://dc-rpall/CP/resetPassword.do?hStr=50585030a9ae6cb4添加到hString对象( )

有人可以帮助我在步骤3中检索mav吗?

0 个答案:

没有答案