package com.tianyi.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping("user") public class UserController { @GetMapping("/test") public Map testDemo(HttpServletRequest request){ Map map = this.getMap(request); return map; } public Map getMap(HttpServletRequest request) { Map map = new HashMap(); Enumeration pNames = request.getParameterNames(); while (pNames.hasMoreElements()) { String name = (String) pNames.nextElement(); String value = request.getParameter(name); if (request.getParameter(name) != null) { map.put(name,value); } String[] values = request.getParameterValues("username"); for(String StringValue:values){ System.out.println(StringValue); } } return map; } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)