edit.jsp

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

JSP
46
字号
<%@ 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);
        }  
%>


<center>
<form action="edit.jsp" method=post name=form>
    <%
        Shopcar c=(Shopcar)session.getAttribute("shopcar");
	Object [] a =c.show();
        Good g;

	for (int i=0; i<a.length; i++) {
           g=(Good)a[i];
    %>
    <input type="radio" name="item" value="<%=g.getName()%>" /><%=g.getName()%> <br>
    <%
	}
    %>
    增加的数量(可以为负):<input type="text" name="mount"/><br>
    <input type=submit value="提交添加">
</form>
</center>
<a href="select.html">continue shopping</a>
<a href="show.jsp">show my shop car</a>
</body>
</html>

⌨️ 快捷键说明

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