📄 puhudianaction.java
字号:
package com.luoin.struts.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import dao.PuhudianDAO;
public class PuhudianAction extends Action{
private PuhudianDAO buhuod = new PuhudianDAO();
private List buhuos = new ArrayList();
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
HttpSession session = request.getSession();
//按日期查询
String year = request.getParameter("bornYear");
String month = request.getParameter("bornMonth");
String day = request.getParameter("bornDay");
String startDate = null;
String endDate = null;
String date = year+"-"+month+"-"+day;
try
{
if(year != null && month.equals("0") && day.equals("0"))
{
startDate = year+"-01-01";
endDate = year+"-12-31";
buhuos = buhuod.findYear(startDate,endDate);
String[] nian = {startDate,endDate,"year"};
session.setAttribute("date", nian);
//年查询
}else if(year != null && month.equals("0")==false && day.equals("0"))
{
startDate = year+"-"+month+"-01";
endDate = year+"-"+month+"-31";
buhuos = buhuod.findMonth(startDate,endDate);
String[] yue = {startDate,endDate,"month"};
session.setAttribute("date", yue);
//月查询
}else if(year != null && month.equals("0")==false && day.equals("0")==false)
{
buhuos = buhuod.findDate(date);
String[] ri = {date,"day","ldy"};
session.setAttribute("date", ri);
//日查询
}else if(year == null && month == null && day == null)
{
String[] temp = (String[])session.getAttribute("date");
if(temp != null && temp[2].equals("year") == true)
{
buhuos = buhuod.findYear(temp[0],temp[1]);
}else if(temp != null && temp[2].equals("month") == true)
{
buhuos = buhuod.findMonth( temp[0],temp[1]);
}else if(temp != null && temp[1].equals("day") == true)
{
buhuos = buhuod.findDate(temp[0]);
}else{
buhuos= buhuod.findAll();
}
}else{
buhuos= buhuod.findAll();
}
}catch(Exception e)
{
e.printStackTrace();
}
request.setAttribute("buhuos", buhuos);
return mapping.findForward("buhuo");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -