JSP接受POST请求参数
代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page import="org.json.JSONObject" %> <%@ page import="weaver.conn.RecordSet" %> <%@ page import="weaver.hrm.User" %> <%@ page import="weaver.hrm.HrmUserVarify" %> <%@ page import="java.io.InputStream" %> <%@ page import="org.apache.commons.io.IOUtils" %> <% request.setCharacterEncoding("utf-8"); String json = request.getParameter("json"); InputStream is= null; is = request.getInputStream(); String data=""; data = IOUtils.toString(is, "utf-8"); response.setContentType("text/json;charset=UTF-8"); out.print(data); %>
另外要注意,不要导入不同的JSON,会有冲突!!!!