简体   繁体   中英

While reset password when after clicking to link from email going to resetPassword jsp page after enter password it's taking whole path

<-----Controller----->

@RequestMapping(value = "/verifyEmail", method = RequestMethod.POST)
public String verifyEmail(@ModelAttribute("signup") Signup signup, ModelMap map,HttpSession session) {
    String emailData = null;
    try {
        list = forgotPasswordService.verifyEmail(signup.getEmail());

    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    if (list.isEmpty()) {
        map.addAttribute("worning", "Invalid Email try again..");
        return "forgotPassword";

    } else {
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            emailData = (String) iterator.next();

        }

    }
    if (emailData.equals(signup.getEmail())) {

        mailUtil.sendMail(signup.getEmail());
        session.setAttribute("email1",signup.getEmail());
        return "checkMail";

    } else {
        System.out.println("---------------");
        return "forgotPassword";
    }
}

@RequestMapping(value = "/resetPassword/{email}", method = RequestMethod.GET)
public String resetPassword(@PathVariable String email,Map<String, String> map) {

    System.out.println("Email: "+email);
    map.put("emailId", email);


    return "resetPassword";
}

@RequestMapping(value = "/passwordChanged", method = RequestMethod.GET)
public String setNewPassword(@ModelAttribute("Signup") Signup signUp, ModelMap map) {

    forgotPasswordService.setNewPassword(signUp.getEmail(), signUp.getPassword());
    map.addAttribute("msg", "Password changed Successfully..");
    return "SignupReg";
}

<-----JSP--->

<form action="passwordChanged" method="get">
    <table>
          <tr>
            <td>Email</td>
            <td><input type="hidden" name="email" value="${email}" readonly ></td>
        </tr> 
        <tr>
            <td>Password</td>
            <td><input type="password" name="password"></td>
        </tr>
         <!-- <tr>
            <td>Conform-Password</td>
            <td><input type="password" name="password1"></td>
        </tr> -->
        <tr> 

            <td><center>
                    <input type="submit" value="Save"/>
                </center></td>

        </tr>

    </table>
</form>

<--- browser -->

url: http://localhost:2525/VendorApp/resetPassword/ 'deepaksahu@gmail.com/passwordChanged?email=%27deepaksahu9119%40gmail.com&password=sahu

error:404 The requested resource is not available.

You have to change the form-method in the first Html/JSP line to "post" . It should look like this:

<form action="passwordChanged" method="post">

You also have to change the line

@RequestMapping(value = "/resetPassword/{email}", method = RequestMethod.GET)

to

@RequestMapping(value = "/resetPassword/{email}", method = RequestMethod.POST)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM