在SpringMVC中使用注解方式传List类型的参数时,要使用@RequestBody注解而不是@RequestParam注解
1 //创建文件夹 2 @RequestMapping(value="api/createFolders",method=RequestMethod.POST) 3 @ResponseBody 4 public ClientResponse<LinkedHashMap<String, BookFsApiJson>> createFolders( 5 @RequestParam("bookId") long bookId, 6 @RequestParam("parentId") long parentId, 7 @RequestBody List<String> paths, 8 HttpServletRequest request) { 9 int userId = loginService.getCurrentUserId(request); 10 LinkedHashMap<String, BookFs> pathBookFsMap = mService.createFolders(bookId, userId, parentId, paths); 11 LinkedHashMap<String, BookFsApiJson> pathBookFsJsonMap = new LinkedHashMap<>(); 12 for (Map.Entry<String, BookFs> entry : pathBookFsMap.entrySet()) { 13 pathBookFsJsonMap.put(entry.getKey(), BookFsConverter.ConvertDomToJson(entry.getValue())); 14 } 15 return ClientResponse.success(pathBookFsJsonMap); 16 }
转载于:https://www.cnblogs.com/jimmy-c/p/4142433.html