我在action里面打印了一下数据,都是正确的。
[color=red]这是我的action[/color]
package action;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import pojo.Dept;
import pojo.User;
import com.opensymphony.xwork2.ActionSupport;
import dao.Dao;
public class JasonAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = -5138636457167442118L;
private List list = new ArrayList();
private Set users = new HashSet();
private Dao dao = new Dao();
public String getUserByDept(){
users = dao.getUserByDept();
return SUCCESS;
}
public String getDept(){
list = dao.getAllDept();
Dept dept = list.get(0);
System.out.println(dept.getDname());
users = dept.getUsers();
System.out.println(users.size());
return "list";
}
public List<Dept> getList() {
return list;
}
public void setList(List<Dept> list) {
this.list = list;
}
public Set<User> getUsers() {
return users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
[color=red]这是struts.xml文件[/color]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
results
[color=red]这是jsp页面[/color]
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
software
hardware
username:
</select>