---
title: "easyuiAction"
author: "past2010"
date: "2013-04-26T21:30:41Z"
tags: []
categories: ["Web前端"]
slug: "easyuiaction"
draft: false
lastmod: "2013-04-14T23:03:15Z"
id: 1847331
url: "https://past2010.iteye.com/blog/1847331"
---

package com.hy.demo.web.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;

import com.hy.demo.common.BaseAction;
import com.hy.demo.modal.Student;
import com.hy.demo.tools.VOUtils;
import com.sdicons.json.model.JSONObject;
import com.sdicons.json.model.JSONValue;
import com.sun.media.rtsp.protocol.Request;

public class StudentAction extends BaseAction {
	private static final long serialVersionUID = 1236034558788877454L;
	JSONObject resultObj;
	
	public JSONObject getResultObj() {
		return resultObj;
	}

	public void setResultObj(JSONObject resultObj) {
		this.resultObj = resultObj;
	}
	JSONValue val;
	

	public JSONValue getVal() {
		return val;
	}

	public void setVal(JSONValue val) {
		this.val = val;
	}

	public String findAll() throws IOException {
		System.out.println("进入StudentAction");
		List<Student> list = new ArrayList();
		Student stu = new Student("1","hy","yy");
		Student stu1 = new Student("2","tt","gg");
		Student stu2 = new Student("3","ee","bb");
		Student stu3 = new Student("4","h","kk");
		list.add(stu);
		list.add(stu1);
		list.add(stu2);
		list.add(stu3);
		
		//List集合转换为Map集合
		Map map = new HashMap();
		map.put("total", list.size());
		map.put("rows", list);
		
		//writeJson(list);
		ServletActionContext.getResponse().getWriter().write(VOUtils.convertVO2String(map));
		System.out.println("发送json字符串完成");
		return null;
	}
}