JSP中获取ExtJS.Ajax前台传递的JSON数据实现过程

网络编程 发布日期:2024/10/20 浏览次数:1

正在浏览:JSP中获取ExtJS.Ajax前台传递的JSON数据实现过程
复制代码 代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="net.sf.json.*" %>
<%
BufferedReader in=request.getReader();
StringBuffer jsonStr=new StringBuffer();
String str="";
while((str=in.readLine())!=null){
jsonStr.append(str);
}
JSONObject jsonObj= JSONObject.fromObject(jsonStr.toString());
String name= jsonObj.getString("userName");
String pwd= jsonObj.getString("passWord");
String msg="";
if(name.equals("Tom")){
msg="登录成功";
}else
{
msg="登录失败";
}
response.getWriter().write(msg);
%>

JSON数据接收的特定过程。
必须的数据包
1.commons-lang.jar
2.commons-beanutils.jar
3.commons-collections.jar
4.commons-logging.jar
5.ezmorph.jar
6.json-lib-2.2.2-jdk15.jar
否则JSONObject 报错,并且不能接收。
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。