1. request.getInputStream()
         /**
         * If the parameter data was sent in the request body, such as occurs
         * with an HTTP POST request, then reading the body directly via
         * @see javax.servlet.ServletRequest#getInputStream or
         * @see javax.servlet.ServletRequest#getReader
         * @param request HttpServletRequest
         * @return String
         */
        public static String getPostData(HttpServletRequest request) {
            StringBuilder data = new StringBuilder();
            String line;
            BufferedReader reader;
            try {
                reader = request.getReader();
                while (null != (line = reader.readLine())) {
                    data.append(line);
                }
            } catch (IOException e) {
                return null;
            }
            return data.toString();
        }

    2、@RequestBody

        @RequestMapping(value = "hello", method = {RequestMethod.POST})
        @ResponseBody
        public String batchDisabledUsers(@RequestBody xxxDTO  xx) {
    
        }
    

    3、@RequestParam

    @RequestMapping(value = "/testurl", method = RequestMethod.POST)
    @ResponseBody
    public StringTestUrl(@RequestParam("username")String username,         
                     @RequestParam("pwd")String pwd)  {
      String txt = username + pwd;
      return txt;
    }

     

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐