今天继续团队作业,完成了销售商品的统计,
package com.wmx.web; import com.wmx.pojo.Login; import com.wmx.pojo.Send; import com.wmx.pojo.User; import com.wmx.service.LoginService; import com.wmx.service.SendService; import com.wmx.service.UserService; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.*; import java.io.IOException; import java.util.ArrayList; import java.util.List; @WebServlet("/sendBynameServlet") public class SendBynameServlet extends HttpServlet { private SendService service = new SendService(); @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String ss[]={"可乐(350ml)","抽纸","湿巾","冰红茶"}; int a; List<Send> s=new ArrayList<>(); // String name=request.getParameter("name"); // String total=request.getParameter("total"); /*List<Send> sends = service.selectByname(name); for(Send send:sends) { System.out.println(send.getMer_phone()); if (send.getName().equals("可乐(350ml)")) { A += send.getTotal(); } if (send.getName().equals("抽纸")) { B += send.getTotal(); }*/ //request.setAttribute("sends",sends); //request.setAttribute("B",B); for(int i=0;i<ss.length;i++){ a=service.selectsum(ss[i]); Send send=new Send(); send.setName(ss[i]); send.setA(a); s.add(send); } request.setAttribute("sends",s); request.getRequestDispatcher("text.jsp").forward(request,response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
标签:wmx,service,记录,每日,request,send,import,com From: https://www.cnblogs.com/xiao-hong111/p/17341603.html