Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Spring MVC RequestMapping拥有多个参数?_Java_Spring_Url_Spring Mvc - Fatal编程技术网

Java 如何使用Spring MVC RequestMapping拥有多个参数?

Java 如何使用Spring MVC RequestMapping拥有多个参数?,java,spring,url,spring-mvc,Java,Spring,Url,Spring Mvc,我在这里使用springmvcRequestMapping来获取GET参数。以下是我的密码- @RequestMapping(value = "index", method = RequestMethod.GET) public HashMap<String, String> handleRequest(@RequestParam("dc1Servers") String dc1Servers) { HashMap<String, String> model =

我在这里使用springmvc
RequestMapping
来获取
GET
参数。以下是我的密码-

@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;
}
所以我做了一个这样的方法,可以接受三个输入参数-

@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;
}
这给了我一些错误。。你知道我在这里做错了什么吗?

应该是这样的

http://127.0.0.1:8080/dataweb/index?dc1Servers=7&dc2Servers=7&dc3Servers=7
请更改并重试

&在每个参数之间工作

??仅在url参数的开头起作用

检查这个例子

你也能帮我吗?谢谢你的帮助。
http://127.0.0.1:8080/dataweb/index?dc1Servers=7?dc2Servers=7?dc3Servers=7
http://127.0.0.1:8080/dataweb/index?dc1Servers=7&dc2Servers=7&dc3Servers=7