lundi 3 août 2015

Can't retrieve ip address from url path, if query strings are present

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);
}




Aucun commentaire:

Enregistrer un commentaire