package com.sxt.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sxt.bean.Goods;
import com.sxt.dao.GoodsDao;
import com.sxt.dao.impl.GoodsDaoImpl;
import com.sxt.util.PageBean;
public class FindGoodsServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
GoodsDao dao = new GoodsDaoImpl();
String gname = request.getParameter("gname");
String pStart = request.getParameter("pStart");
String pEnd = request.getParameter("pEnd");
String dStart = request.getParameter("dStart");
String dEnd = request.getParameter("dEnd");
String gstatus = request.getParameter("gstatus");
int page = Integer.parseInt(request.getParameter("page"));
int rows = Integer.parseInt(request.getParameter("rows"));
PrintWriter out = response.getWriter();
try {
PageBean pb = dao.findGoods(gname, pStart, pEnd, dStart, dEnd,
gstatus,page,rows);
ObjectMapper om = new ObjectMapper();
String json = om.writeValueAsString(pb);
out.print(json);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}