1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <%@ page import="java.util.ArrayList" %> <%@ page import="java.lang.reflect.Array" %> <%@ page import="java.util.Arrays" %><%-- Created by IntelliJ IDEA. User: DELL Date: 2022/9/18 Time: 17:18 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=GBK" language="java" %> <html> <head> <title>Title</title> </head> <body> <% request.setCharacterEncoding("GBK"); String[] goods = request.getParameterValues("goods"); if(goods == null){ out.println("您没有选中的物品"); out.println("<a href='goods.jsp'>返回商店</a>"); } else{ out.println("您确定要购买:"); for(String t:goods){ out.print(t+' '); } out.println('?'); ArrayList<String> carts = (ArrayList<String>)session.getAttribute("carts"); if(carts==null){ carts = new ArrayList<String>(); } ArrayList<String> carts_add = (ArrayList<String>)session.getAttribute("carts_add"); if(carts_add==null){ carts_add = new ArrayList<String>(); } for(String t:goods){ if(!carts.contains(t)){ carts_add.add(t); } } session.setAttribute("carts_add",carts_add); %> <a href="carts_yes.jsp">是</a> <a href="carts_no.jsp">否</a> <% } %> </body> </html>
|