0

I try doing confirmation registration from email, on the email I send this code:

    String token = UUID.randomUUID().toString();  //for send email
    String confirmationUrl =  "<a href='" +
            "http://localhost:8080/registrationConfirm.html?token="
            + token+"'>Click for end Registration</a>";
    helper.setText("message", confirmationUrl.toString());

I receive something like this:

I want doing a new controller, he will be check if 88ab5907-6ab5-40e2-89d5-d6a7e8cea3c2 exist in DB, then he activated registration, if no - talk about misstake. And I do not understand how the conroller will be look, I do so

@RequestMapping(value = "/token", method = RequestMethod.POST)
public @ResponseBody
String getAttr(@PathVariable(value="token") String id,
           ) {
    System.out.println(id);
    return id;
   }
Viking
  • 177
  • 5
  • 16
  • Possible duplicate of [Get Query String Values in Spring MVC Controller](http://stackoverflow.com/questions/17934972/get-query-string-values-in-spring-mvc-controller) – Ali Dehghani Aug 23 '16 at 07:01
  • I want doing a new controller, he will be check if `88ab5907-6ab5-40e2-89d5-d6a7e8cea3c2` exist in DB, then he activated registration, if no - talk about misstake – Viking Aug 23 '16 at 08:25

2 Answers2

0

To complete the comment and hint Ali Dehghani has given (have a look at the answer https://stackoverflow.com/a/17935468/265043):

@RequestMapping(value = "/registrationConfirm", method = RequestMethod.POST)
public @ResponseBody
String getAttr(@RequestParam(value="token") String id) {
  System.out.println(id);
  return id;
}

Note that I ignored the html suffix in the request mapping annotation. You should read the docs about (default) content negotiation starting at http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-suffix-pattern-match

Community
  • 1
  • 1
meistermeier
  • 7,942
  • 2
  • 36
  • 45
0

this another variant

@RequestMapping(value = "/registrationConfirm", method = RequestMethod.POST)  
 public void getMeThoseParams(HttpServletRequest request){
            String goToURL = request.getParameter("token");
            System.out.println(goToURL);
        }
Viking
  • 177
  • 5
  • 16