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,082,665
  • 372
  • 3,610
  • 3,555
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596

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,922
  • 1
  • 15
  • 29