日期:2014-05-20 浏览次数:20879 次
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String searchName= new String(request.getParameter("txtPname").getBytes("ISO8859-1"),"UTF-8"); ProductDao productDao = new ProductDao(); try { ArrayList<Product> productList = productDao.search(searchName); HttpSession session = request.getSession(); session.setAttribute("productList", productList); if(productList.isEmpty()){ productList = null; productList=productDao.selectAll(); session= request.getSession(); session.setAttribute("productList", productList); request.getRequestDispatcher("/ProductList.jsp").forward(request, response); //想在这里加入输出到页面的String }else{ request.getRequestDispatcher("/ProductList.jsp").forward(request, response); } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }