You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.7 KiB
114 lines
2.7 KiB
package com.action;
|
|
|
|
import com.bean.DomitoryBean;
|
|
import com.bean.LogBean;
|
|
import com.dao.DomitoryDao;
|
|
import com.dao.LogDao;
|
|
import com.opensymphony.xwork2.ActionSupport;
|
|
import org.apache.struts2.ServletActionContext;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpSession;
|
|
import java.io.PrintWriter;
|
|
import java.util.List;
|
|
|
|
|
|
public class MyLogList extends ActionSupport {
|
|
|
|
//下面是Action内用于封装用户请求参数的属性
|
|
private List<LogBean> list;
|
|
public List<LogBean> getList() {
|
|
return list;
|
|
}
|
|
public void setList(List<LogBean> list) {
|
|
this.list = list;
|
|
}
|
|
|
|
|
|
private String Building_ID;
|
|
public String getBuilding_ID() {
|
|
return Building_ID;
|
|
}
|
|
public void setBuilding_ID(String buildingID) {
|
|
Building_ID = buildingID;
|
|
}
|
|
private List<DomitoryBean> domitorylist;
|
|
public List<DomitoryBean> getDomitorylist() {
|
|
return domitorylist;
|
|
}
|
|
public void setDomitorylist(List<DomitoryBean> domitorylist) {
|
|
this.domitorylist = domitorylist;
|
|
}
|
|
|
|
private String SearchRow;
|
|
private String SearchKey;
|
|
public String getSearchRow() {
|
|
return SearchRow;
|
|
}
|
|
public void setSearchRow(String searchRow) {
|
|
SearchRow = searchRow;
|
|
}
|
|
public String getSearchKey() {
|
|
return SearchKey;
|
|
}
|
|
public void setSearchKey(String searchKey) {
|
|
SearchKey = searchKey;
|
|
}
|
|
private String Domitory_ID;
|
|
|
|
public String getDomitory_ID() {
|
|
return Domitory_ID;
|
|
}
|
|
public void setDomitory_ID(String domitoryID) {
|
|
Domitory_ID = domitoryID;
|
|
}
|
|
//处理用户请求的execute方法
|
|
public String execute() throws Exception {
|
|
|
|
//解决乱码,用于页面输出
|
|
HttpServletResponse response=null;
|
|
response=ServletActionContext.getResponse();
|
|
response.setContentType("text/html;charset=UTF-8");
|
|
response.setCharacterEncoding("UTF-8");
|
|
PrintWriter out = response.getWriter();
|
|
|
|
//创建session对象
|
|
HttpSession session = ServletActionContext.getRequest().getSession();
|
|
//验证是否正常登录
|
|
if(session.getAttribute("id")==null){
|
|
out.print("<script language='javascript'>alert('请重新登录!');window.location='Login.jsp';</script>");
|
|
out.flush();out.close();return null;
|
|
}
|
|
|
|
//查询条件
|
|
String strWhere="Student_State='入住' and Building_ID="+Building_ID;
|
|
if(!(isInvalid(SearchKey)))
|
|
{
|
|
strWhere+=" and "+SearchRow+"='"+SearchKey+"'";
|
|
}
|
|
if(!(isInvalid(Domitory_ID)))
|
|
{
|
|
strWhere+=" and Domitory_ID='"+Domitory_ID+"'";
|
|
}
|
|
//查询所有
|
|
list=new LogDao().GetList(strWhere,"Log_Date desc");
|
|
|
|
//查询所有寝室
|
|
domitorylist=new DomitoryDao().GetList("Domitory_BuildingID="+Building_ID,"Domitory_Name");
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
//判断是否空值
|
|
private boolean isInvalid(String value) {
|
|
return (value == null || value.length() == 0);
|
|
}
|
|
|
|
//测试
|
|
public static void main(String[] args) {
|
|
System.out.println();
|
|
}
|
|
|
|
}
|