📄 balanceservlet.java
字号:
package family.yin.senqi;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Date;
import java.util.Calendar;
import family.yin.senqi.dao.MyDAO;
import family.yin.senqi.model.ModelFour;
import java.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class BalanceServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
HttpSession session = req.getSession();
Calendar c = Calendar.getInstance();
int nYear = c.get(1);
int nMonth = c.MONTH+1;
String nYear_str = req.getParameter("nYear");
String nMonth_str = req.getParameter("nMonth");
if(nMonth_str!=null && nYear_str!=null){
nMonth = new Integer(nMonth_str).intValue();
}
MyDAO dao = new MyDAO();
try {
ModelFour[] mf = dao.getBalance(nYear, nMonth);
session.setAttribute("mf",mf);
float mTotal = dao.getMonthTotalMoney(nMonth);
session.setAttribute("mTotal",new Float(mTotal));
}
catch (SQLException ex) {
ex.printStackTrace();
}
resp.sendRedirect("balance.jsp?nYear="+nYear+"&nMonth="+nMonth);
}
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
this.doPost(req,resp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -