SPR-6021 - Allow for using MultiValueMap in GET request for mapping multiple request params

This commit is contained in:
Arjen Poutsma
2010-03-22 14:31:27 +00:00
parent 19b4618fb5
commit c9289a4dcf
2 changed files with 13 additions and 64 deletions

View File

@@ -1352,23 +1352,11 @@ public class ServletAnnotationControllerTests {
public void requestHeaderMap() throws Exception {
initServlet(RequestHeaderMapController.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/map");
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/httpHeaders");
request.addHeader("Content-Type", "text/html");
request.addHeader("Custom-Header", new String[]{"value21", "value22"});
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("Content-Type=text/html,Custom-Header=value21", response.getContentAsString());
request.setRequestURI("/multiValueMap");
response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("Content-Type=[text/html],Custom-Header=[value21,value22]", response.getContentAsString());
request.setRequestURI("/httpHeaders");
response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("Content-Type=[text/html],Custom-Header=[value21,value22]", response.getContentAsString());
}
@@ -2439,21 +2427,9 @@ public class ServletAnnotationControllerTests {
@Controller
public static class RequestHeaderMapController {
@RequestMapping("/map")
public void map(@RequestHeader Map<String, String> headers, Writer writer) throws IOException {
for (Iterator<Map.Entry<String, String>> it = headers.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, String> entry = it.next();
writer.write(entry.getKey() + "=" + entry.getValue());
if (it.hasNext()) {
writer.write(',');
}
}
}
@RequestMapping("/multiValueMap")
public void multiValueMap(@RequestHeader MultiValueMap<String, String> headers, Writer writer)
throws IOException {
@RequestMapping("/httpHeaders")
public void httpHeaders(HttpHeaders headers, Writer writer) throws IOException {
assertEquals("Invalid Content-Type", new MediaType("text", "html"), headers.getContentType());
for (Iterator<Map.Entry<String, List<String>>> it1 = headers.entrySet().iterator(); it1.hasNext();) {
Map.Entry<String, List<String>> entry = it1.next();
writer.write(entry.getKey() + "=[");
@@ -2471,12 +2447,6 @@ public class ServletAnnotationControllerTests {
}
}
@RequestMapping("/httpHeaders")
public void httpHeaders(@RequestHeader HttpHeaders headers, Writer writer) throws IOException {
assertEquals("Invalid Content-Type", new MediaType("text", "html"), headers.getContentType());
multiValueMap(headers, writer);
}
}
public interface IMyController {