📄 incomelistservlet.java
字号:
package com.yiboit.cfss.income;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class IncomeListServlet extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String cmd = request.getParameter("cmd");
// 取得用户选择的年月日
String year = request.getParameter("year");
String month = request.getParameter("month");
String day = request.getParameter("day");
String orderby = request.getParameter("orderby");
if (orderby == null || orderby.length() == 0) {
orderby = "dept_name";
}
HttpSession session = request.getSession();
try {
IncomeDAO dao = new IncomeDAO();
if (cmd == null) {
// 取得检索条件中的可用年份
List yearList = dao.getYears();
session.setAttribute("yearList", yearList);
Calendar now = Calendar.getInstance(); // 取得当前日期
year = "" + now.get(Calendar.YEAR);
month = "" + (now.get(Calendar.MONTH) + 1);
day = "" + now.get(Calendar.DAY_OF_MONTH);
} else if ("search".equals(cmd)) {
//
}
List<IncomeBean> incomeList = dao.getIncomeList(year, month, day, orderby);
request.setAttribute("incomeList", incomeList);
request.setAttribute("year", year);
request.setAttribute("month", month);
request.setAttribute("day", day);
request.getRequestDispatcher("incomeList.jsp").forward(request,
response);
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect(request.getContextPath() + "/error.jsp");
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -