0

This is my get method in spring boot

@GetMapping(value="/generateotp/{username}")
    public String generateOTP(@PathVariable(value = "username") String userName) {
        loginService.generateOTP(userName);
        return "OTP Generated";
    }

From my rest client I'm hitting with Url

http://localhost:8080/generateotp/shaik.moulali

But It is taking only shaik, it is neglecting after '.' part. But when I'm giving Url like http://localhost:8080/generateotp/shaikmoulali. It is accepting. Can I know the reason.

Moulali
  • 465
  • 1
  • 6
  • 17
  • 2
    duplicate of https://stackoverflow.com/questions/16332092/spring-mvc-pathvariable-with-dot-is-getting-truncated – Mumrah81 Jan 23 '18 at 08:20

3 Answers3

0

If you want use some special characters, you have to set up a regex for Spring. See this link https://stackoverflow.com/questions/16332092/spring-mvc-pathvariable-with-dot-is-getting-truncated

iLucas97
  • 15
  • 1
  • 5
0

By adding a / at the end of the url solved the issue.

http://localhost:8080/generateotp/shaik.moulali/

We can also solve this by giving that parameter in body as post request.

Moulali
  • 465
  • 1
  • 6
  • 17
0

. is not a valid in the way you are using. If a value is to be used in url they should be properly escaped. (shaik%2Emoulali)

Char that needs to be escaped.

So when you are making call to your controller try to send encoded url and that should work.

Ekansh Rastogi
  • 2,418
  • 2
  • 14
  • 23