1

I am using Spring MVC RequestMapping here for GET parameters. Below is my code -

@RequestMapping(value = "index", method = RequestMethod.GET)
public HashMap<String, String> handleRequest(@RequestParam("dc1Servers") String dc1Servers) {
    HashMap<String, String> model = new HashMap<String, String>();
    String helloWorld = "Hello World!";
    model.put("greeting", helloWorld);

    System.out.println(dc1Servers);

    return model;
}

I am hitting this URL - http://127.0.0.1:8080/dataweb/index?dc1Servers=7 then it goes into the above code and prints out 7 on the console and works fine.

Now I would like to have these two below parameters as well -

dc2Servers=7
dc3Servers=7

So I made a method like this which can take three input parameters -

@RequestMapping(value = "index", method = RequestMethod.GET)
public HashMap<String, String> handleRequest(@RequestParam("dc1Servers") String dc1Servers, @RequestParam("dc2Servers") String dc2Servers, @RequestParam("dc3Servers") String dc3Servers) {
    HashMap<String, String> model = new HashMap<String, String>();
    String helloWorld = "Hello World!";
    model.put("greeting", helloWorld);

    System.out.println(dc1Servers);
    System.out.println(dc2Servers);
    System.out.println(dc3Servers);

    return model;
}

Now if I hit the url like this then it doesn't works -

http://127.0.0.1:8080/dataweb/index?dc1Servers=7?dc2Servers=7?dc3Servers=7

And it gives me some error.. Any idea what wrong I am doing here?

1 Answer 1

3

This should be

http://127.0.0.1:8080/dataweb/index?dc1Servers=7&dc2Servers=7&dc3Servers=7

change an try again

& works between each parameter

? only works at the begin of the url parameters

Check this example

http://www.example.com/products/women/dresses?sessionid=34567&source=google.com

Sign up to request clarification or add additional context in comments.

1 Comment

Can you help me on this question as well? Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.