欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Servlet处理Json请求数据包

程序员文章站 2022-06-17 16:07:24
...
request.setCharacterEncoding('UTF-8'); response.setContentType('text/html;charset=UTF-8');
String acceptjson = ''; 
BufferedReader br = new BufferedReader(new InputStreamReader( (ServletInputStream)
request.getInputStream(), 'utf-8'));
StringBuffer sb = new StringBuffer('');
String temp; 
while ((temp = br.readLine()) != null)
{ 
    sb.append(temp); 
}
br.close();
acceptjson = sb.toString();