按条件
查询订单
创建Servlet
单击“查询”,提交表单,发送“/findOrderByManyCondition”,由FindOrderByManyConditionServlet处理
public class FindOrderByManyConditionServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获取订单编号和收件人名称
String id = request.getParameter("id");
String receiverName = request.getParameter("receiverName");
//创建Service层对象
OrderService service = new OrderService();
//调用Service层OrderService类的findOrderByManyCondition()方法查询数据
List orders = service.findOrderByManyCondition(id, receiverName);
//将查询结果添加到request作用域中
request.setAttribute("orders", orders);
//请求转发到list.jsp页面,并将request请求和response响应也转发到该页面中
request.getRequestDispatcher("/admin/orders/list.jsp").forward(request,
response);
}
}
编写Service层方法
// 多条件查询订单信息
public List findOrderByManyCondition(String id, String receiverName) {
List orders = null;
try {
orders = odao.findOrderByManyCondition(id, receiverName);
} catch (SQLException e) {
e.printStackTrace();
}
return orders;
}
编写DAO层方法
public List findOrderByManyCondition(String id, String receiverName)
throws SQLException {
//1.创建集合对象
List
评论列表(0条)