servlet层
package servlet; import java.util.List; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import Dao.Dao; import Bean.Diqu; import Bean.Sheng; @WebServlet("/Servlet") public class Servlet extends HttpServlet { private static final long serialVersionUID = 1L; public Servlet() { super(); } protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); String method = req.getParameter("method"); if ("tcha".equals(method)) { tcha(req,resp); } } private void tcha(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{ String []m=new String[34]; req.setCharacterEncoding("utf-8"); Dao dao =new Dao(); HttpSession session = req.getSession(); String time = (req.getParameter("time")); String locate= (req.getParameter("locate")); List<Diqu> holds = dao.tcha(time,locate); List<Sheng> holds1 = dao.Scha(time); for(int i = 0; i < holds1.size(); i++){ Sheng d=holds1.get(i); m[i]=d.getPerson(); } System.out.println(m[0]); req.setAttribute("m", m); req.setAttribute("holds", holds); req.getRequestDispatcher("index.jsp").forward(req,resp); } }