HttpServletRequest获取post的参数

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

HttpServletRequest获取post的参数 同事的错误写法:

    public @ResponseBody String registerLogin(HttpServletRequest request, HttpServletResponse response) {
//        String userName = request.getParameter("userName");

正确:

try {
    BufferedReader reader = request.getReader();
    while ((line = reader.readLine()) != null)
        sb.append(line);
    service = sb.toString();
} catch (Exception e) {
    e.printStackTrace();
}

转载于:https://my.oschina.net/u/2464371/blog/2933755

你可能感兴趣的:(HttpServletRequest获取post的参数)