package com.andon.mao.user.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.andon.mao.user.entity.User;
import com.opensymphony.xwork2.ActionSupport;
/**
* @author mao
* @date Date:2014-6-15 Time: 上午09:29:05
* @version 1.0
*/
@SuppressWarnings("serial")
public class UserAction extends ActionSupport {
private String json;// json字符串
private User jsonObject;// json对象
private List<User> jsonList;// json数组
private Map<String, Object> jsonMap;// jsonMap
/**
* 初始化各种json储存对象
* @init()
*/
public UserAction() {
this.json = new String();
this.jsonObject = new User();
this.jsonList = new ArrayList<User>();
this.jsonMap = new HashMap<String, Object>();
}
/**
* struts2序列化对象的时候,要返回的方法必须要有getter方法 rn
*/
public String getJson() {
return json;
}
public User getJsonObject() {
return jsonObject;
}
public List<User> getJsonList() {
return jsonList;
}
public Map<String, Object> getJsonMap() {
return jsonMap;
}
/**
* 返回json字符串
* @date Date:2014-6-15 Time: 上午09:39:19
* @return String
*/
public String returnJson() throws Exception {
System.out.println("json");
this.json = "this is a String json to do";
// return super.execute();
return "json";
}
/**
* 返回json对象
* @date Date:2014-6-15 Time: 上午09:40:29
* @return Object
*/
public String returnJsonObject() throws Exception {
System.out.println("jsonObject");
this.jsonObject.setUserId(1);
this.jsonObject.setUserName("json");
this.jsonObject.setPassword("Object to json by struts2");
return "jsonObject";
}
/**
* 返回json数组
* @date Date:2014-6-15 Time: 上午09:40:59
* @return jsonList
*/
public String returnJsonList() throws Exception {
System.out.println("jsonList");
User jsonObject = new User();
jsonObject.setUserId(1);
jsonObject.setUserName("userName");
jsonObject.setPassword("userPwd");
User jsonObject1 = new User();
jsonObject1.setUserId(2);
jsonObject1.setUserName("userName1");
jsonObject1.setPassword("userPwd1");
User jsonObject2 = new User();
jsonObject2.setUserId(3);
jsonObject2.setUserName("userName2");
jsonObject2.setPassword("userPwd2");
this.jsonList.add(jsonObject);
this.jsonList.add(jsonObject1);
this.jsonList.add(jsonObject2);
return "jsonList";
}
/**
* 返回jsonMap
* @date Date:2014-6-15 Time: 上午09:41:34
* @return jsonMap
*/
public String returnJsonMap() throws Exception {
System.out.println("jsonMap");
User jsonObject = new User();
jsonObject.setUserId(1);
jsonObject.setUserName("userName");
jsonObject.setPassword("userPwd");
User jsonObject1 = new User();
jsonObject1.setUserId(2);
jsonObject1.setUserName("userName1");
jsonObject1.setPassword("userPwd1");
User jsonObject2 = new User();
jsonObject2.setUserId(3);
jsonObject2.setUserName("userName2");
jsonObject2.setPassword("userPwd2");
this.jsonMap.put("1", jsonObject);
this.jsonMap.put("2", jsonObject1);
this.jsonMap.put("3", jsonObject2);
return "jsonMap";
}
}

Just小刚
- 粉丝: 0
最新资源
- XW万能铣床电控系统的PLC设计[].doc
- 基于Laravel54与Vuejs构建的本地文档全文搜索引擎系统-集成Elasticsearch551实现高效索引与检索-支持用户笔记与开发文档的智能搜索与管理-采用PHP.zip
- 某类国防工程信息化管理系统项目需求及方案设计.docx
- 图像灰度变化程序设计.doc
- 操作系统处理器调度算法C++程序.doc
- “嵌入式产品开发”项目竞赛技术方案.doc
- 土地测绘技术的信息化与土地开发管理措施.docx
- 2018年百万公众网络学习工程测试参考答案.doc
- C语言程序设计2014春第三套作业.docx
- 大数据下的不动产登记档案的信息管理及利用.docx
- 大楼综合布线设计方案.docx
- 微信公众平台对高校网络舆论影响的研究.docx
- 试卷分析模型构建--基于教育大数据的实证分析.docx
- 网络金融学教案全解.doc
- 新互联网下高职计算机专业教学模式改革初探.docx
- 大数据环境下开放信息资源共享平台构建.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
前往页