0

I am having a problem retrieving IP address from URL path. I am using Spring MVC for handling request and response. I can retrieve IP address from URL path if there's no query string included in URL, but if I include query string in URL I get only half of the IP string. For example: If I send a GET request in the http://localhost:8080/api/ip/10.2.2.1 (note that query string is not included), I can successfully get ip string. But if i send a GET request in http://localhost:8080/api/ip/10.2.2.1?status=200 (note that query string is included), I get 10.2.2 ip and status 200. I am wondering where did my .1 go. I can also retrieve status value successfully. I think I am missing some HTTP standard here, but what could it be?

Here's my code snippet for get path variable and query string:

@RequestMapping("/{ip}")
public void getIpAndStatus(@PathVariable("ip") String ip, @RequestParam("status") String status) {
    System.out.println(" - IP Address: " + ip);
    System.out.println(" - Status: " + status);
}
Mani Rai
  • 665
  • 2
  • 9
  • 22
  • what do you get for `ip` when using `http://localhost:8080/api/ip/foobar?status=200`? –  Aug 04 '15 at 05:49
  • I am getting exact value as expected. foobar for ip and 200 for status. – Mani Rai Aug 04 '15 at 06:20
  • 1
    possible duplicate of [Spring - Path variable truncate after dot - annotation](http://stackoverflow.com/questions/27419743/spring-path-variable-truncate-after-dot-annotation) –  Aug 04 '15 at 07:05
  • 2
    SpringMVC thinks the last `.1` in your IP is an extension, see duplicate –  Aug 04 '15 at 07:06

0 Answers0