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

将json数据提交到action并解析

程序员文章站 2022-03-26 09:53:24
...
ajax将json数据提交到action并解析



Insert title here
Action代码如下: package controller; import com.opensymphony.xwork2.ActionSupport; import net.sf.json.JSONObject; public class GetJSON extends ActionSupport{ private String jsonString; public String getJsonString(){ return this.jsonString; } public void setJsonString(String jsonString){ this.jsonString = jsonString; } @Override public String execute() throws Exception { System.out.println(jsonString); JSONObject json = JSONObject.fromObject(jsonString); System.out.println("username=" + json.get("username")); System.out.println("password=" + json.get("password")); System.out.println("age=" + json.get("age")); System.out.println("BigText=" + json.get("BigText")); return null; } }
相关标签: ajax struts2