gogozz

导航

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,会有冲突!!!!

posted on 2023-11-20 16:21  stfzhuang  阅读(319)  评论(0编辑  收藏  举报