1

I am finding some difficulties with this particular case of path variable use in Spring MVC.

So I open an URL like this:

localhost:8080/my-project/utenze/my.username/confermaEmail/my.email@google.com

Into my controller class I have this controller method that handle URL like this:

@RequestMapping(value = "utenze/{username}/confermaEmail/{email}", method = RequestMethod.GET)
    public String confermaModificaEmail(@RequestHeader(value = HEADER_USER_CG) String codicefiscale, 
                                        @PathVariable String username, @PathVariable String email, Model model)  {

        logger.info("INTO confermaModificaEmail(), indirizzo e-mail: " + email);

        ...................................................................
        ...................................................................
        ...................................................................

        return "myView";
}

The previous request is correctly handled but I have the following problem with the email path variable value.

The problem is that the email path variable value is not my.emai@google.com as I expect but it is my.emai@google.

Spring is automatically deleting the last .com section of the inserted value.

Why? What is the problem? What am I missing? How can I try to solve this issue?

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
AndreaNobili
  • 38,251
  • 94
  • 277
  • 514

1 Answers1

2

In your case I would remove the {email} from the path variable and request it via the request parameter:

@RequestMapping(value = "utenze/{username}/confermaEmail", method = RequestMethod.GET)
public String confermaModificaEmail(@RequestHeader(value = HEADER_USER_CG) String codicefiscale, 
                                    @PathVariable String username, @RequestParam(value="email", required=true) String email, Model model)  {

    logger.info("INTO confermaModificaEmail(), indirizzo e-mail: " + email);

    ...................................................................
    ...................................................................
    ...................................................................

    return "myView";}

Have a try at this =)

Roel Strolenberg
  • 2,892
  • 1
  • 13
  • 29