首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Extjs+Struts2 Ajax 模式提交数据

2012-10-20 
Extjs+Struts2 Ajax 方式提交数据前台Ext 代码??LoginAction.java?public String execute() {Watch watch

Extjs+Struts2 Ajax 方式提交数据

前台Ext 代码

?

?LoginAction.java

?

public String execute() {Watch watch = new Watch();watch.setNum(1);watch.setOnLine("asdfasdf");JSONObject jo = JSONObject.fromObject(watch);String jsonStr = jo.toString();System.out.println(jsonStr);try {// 返回成功标识response.getWriter().println("{success:true}");response.getWriter().println("{watch:"+jsonStr+"}");response.getWriter().flush();} catch (IOException e) {e.printStackTrace();} finally {try {response.getWriter().close();} catch (IOException e) {e.printStackTrace();}}return null;}

?java转json格式需要的jar包如下

? ?commons-beanutils.jar
???commons-collections-3.2.jar
???commons-lang-2.3.jar
???commons-logging.jar
???ezmorph-1.0.6.jar
???json-lib-2.4-jdk15.jar

?

热点排行
Bad Request.