show.jsp

来自「传递多种物品」· JSP 代码 · 共 47 行

JSP
47
字号
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.util.*" %>
<%@page import="shopcar.*" %>
<%@page import="shopcar.good.*" %>
<html>
<body>
<%

        request.setCharacterEncoding("GBK");
        if(request.getParameter("item")!=null && !"".equals(request.getParameter("mount"))){
           Good g=new Good();
           g.setName(request.getParameter("item"));
           g.setMount(Integer.parseInt(request.getParameter("mount")));    

           Shopcar car=(Shopcar)session.getAttribute("shopcar");
           if(car==null) {
              car=new Shopcar();
           }
     
           car.addGood(g);
           session.setAttribute("shopcar",car);
        }
%>
<FONT size = 5 COLOR="#CC0000">
<br> You have the following items in your cart:
<ol>
    <% 
        Shopcar c=(Shopcar)session.getAttribute("shopcar");
	Object [] a =c.show();
        Good g;
	for (int i=0; i<a.length; i++) {
           g=(Good)a[i];
    %>
    <li> name:<%=g.getName()%> count:<%=g.getMount()%>        
    <%
	}
    %>
</ol>
</FONT>
<hr>
<h1>
<a href="select.html">continue shopping</a>
<br><br>
<a href="edit.jsp">edit my shopcar</a>
</h1>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?