⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cartview_0002ejsp_jsp.java

📁 购物车模块实例。购物车模块可以浏览商品类别;可以根据商品类别浏览商品信息;可以购买商品;可以查看购物车的商品;可以修改购买商品的数量和删除购买的商品。
💻 JAVA
字号:
import data.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;


public class cartview_0002ejsp_jsp extends HttpJspBase {


    static {
    }
    public cartview_0002ejsp_jsp( ) {
    }

    private static boolean _jspx_inited = false;

    public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse  response)
        throws java.io.IOException, ServletException {

        JspFactory _jspxFactory = null;
        PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        String  _value = null;
        try {

            if (_jspx_inited == false) {
                synchronized (this) {
                    if (_jspx_inited == false) {
                        _jspx_init();
                        _jspx_inited = true;
                    }
                }
            }
            _jspxFactory = JspFactory.getDefaultFactory();
            response.setContentType("text/html; charset=GBK");
            pageContext = _jspxFactory.getPageContext(this, request, response,
            			"", true, 8192, true);

            application = pageContext.getServletContext();
            config = pageContext.getServletConfig();
            session = pageContext.getSession();
            out = pageContext.getOut();

            // HTML // begin [file="/cartview.jsp";from=(0,48);to=(1,0)]
                out.write("\r\n");

            // end
            // HTML // begin [file="/cartview.jsp";from=(1,38);to=(9,0)]
                out.write("\r\n<html>\r\n<head>\r\n<title>购物车浏览页面</title>\r\n</head>\r\n<body>\r\n<center>\r\n<h3>购物车浏览页面</h3>\r\n");

            // end
            // begin [file="/cartview.jsp";from=(9,2);to=(14,0)]
                
                  //取得session的购物车对象
                  Cart cart = (Cart)session.getAttribute("cart");
                  //取得购物车的商品数组
                  Object[][] goodsObjs = cart.getGoodsobjs();
            // end
            // HTML // begin [file="/cartview.jsp";from=(14,2);to=(31,45)]
                out.write("\r\n<form action=\"cartview\" method=\"post\">\r\n<table cellpadding=\"5\" cellspacing=\"0\" border = \"1\">\r\n  <tr align=\"center\">\r\n    <td colspan=\"2\"><input name=\"action\" type=\"submit\" value=\"修改购物车的数量\"></td>\r\n    <td colspan=\"2\"><input name=\"action\" type=\"submit\" value=\"删除选择商品\"></td>\r\n    <td colspan=\"3\"><input name=\"action\" type=\"submit\" value=\"重新显示购物车的商品\"></td>\r\n  </tr>\r\n  <tr align=\"center\">\r\n    <td>序号</td>\r\n    <td>商品名字</td>\r\n    <td>单位数量</td>\r\n    <td>单价</td>\r\n    <td>是否修改</td>\r\n    <td>数量</td>\r\n    <td>金额</td>\r\n  </tr>\r\n<input name=\"idsLength\" type=\"hidden\" value=\"");

            // end
            // begin [file="/cartview.jsp";from=(31,48);to=(31,64)]
                out.print(goodsObjs.length);
            // end
            // HTML // begin [file="/cartview.jsp";from=(31,66);to=(32,0)]
                out.write("\">\r\n");

            // end
            // begin [file="/cartview.jsp";from=(32,2);to=(34,0)]
                
                for(int i=0; i < goodsObjs.length - 1; i++){
            // end
            // HTML // begin [file="/cartview.jsp";from=(34,2);to=(37,10)]
                out.write("\r\n    <!--通过表格显示商品数组的数据-->\r\n    <tr>\r\n      <td>");

            // end
            // begin [file="/cartview.jsp";from=(37,13);to=(37,20)]
                out.print((i + 1));
            // end
            // HTML // begin [file="/cartview.jsp";from=(37,22);to=(38,6)]
                out.write("</td>\r\n      ");

            // end
            // HTML // begin [file="/cartview.jsp";from=(38,28);to=(39,6)]
                out.write("\r\n      ");

            // end
            // begin [file="/cartview.jsp";from=(39,8);to=(39,33)]
                for(int j=1; j < 4; j++){
            // end
            // HTML // begin [file="/cartview.jsp";from=(39,35);to=(40,12)]
                out.write("\r\n        <td>");

            // end
            // begin [file="/cartview.jsp";from=(40,15);to=(40,30)]
                out.print(goodsObjs[i][j]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(40,32);to=(41,6)]
                out.write("</td>\r\n      ");

            // end
            // begin [file="/cartview.jsp";from=(41,8);to=(41,9)]
                }
            // end
            // HTML // begin [file="/cartview.jsp";from=(41,11);to=(42,6)]
                out.write("\r\n      ");

            // end
            // HTML // begin [file="/cartview.jsp";from=(42,23);to=(44,28)]
                out.write("\r\n      <td align=\"center\">\r\n        <input name=\"goodsId");

            // end
            // begin [file="/cartview.jsp";from=(44,31);to=(44,32)]
                out.print(i);
            // end
            // HTML // begin [file="/cartview.jsp";from=(44,34);to=(45,13)]
                out.write("\" type=\"checkbox\" value=\"\r\n             ");

            // end
            // begin [file="/cartview.jsp";from=(45,16);to=(46,37)]
                out.print(goodsObjs[i][0] + "@@" + goodsObjs[i][1] + "@@" + goodsObjs[i][2]
             + "@@" + goodsObjs[i][3]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(46,39);to=(48,6)]
                out.write("\">\r\n      </td>\r\n      ");

            // end
            // HTML // begin [file="/cartview.jsp";from=(48,18);to=(50,29)]
                out.write("\r\n      <td>\r\n        <input name=\"quantity");

            // end
            // begin [file="/cartview.jsp";from=(50,32);to=(50,33)]
                out.print(i);
            // end
            // HTML // begin [file="/cartview.jsp";from=(50,35);to=(50,66)]
                out.write("\" type=\"text\" size=\"15\" value=\"");

            // end
            // begin [file="/cartview.jsp";from=(50,69);to=(50,84)]
                out.print(goodsObjs[i][4]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(50,86);to=(52,6)]
                out.write("\">\r\n      </td>\r\n      ");

            // end
            // HTML // begin [file="/cartview.jsp";from=(52,18);to=(54,8)]
                out.write("\r\n      <td>\r\n        ");

            // end
            // begin [file="/cartview.jsp";from=(54,11);to=(54,26)]
                out.print(goodsObjs[i][5]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(54,28);to=(57,0)]
                out.write("\r\n      </td>\r\n    </tr>\r\n");

            // end
            // begin [file="/cartview.jsp";from=(57,2);to=(59,0)]
                
                }
            // end
            // HTML // begin [file="/cartview.jsp";from=(59,2);to=(63,6)]
                out.write("\r\n<tr>\r\n  <td>总金额</td>\r\n  <td colspan=\"2\">&nbsp;</td>\r\n  <td>");

            // end
            // begin [file="/cartview.jsp";from=(63,9);to=(63,43)]
                out.print(goodsObjs[goodsObjs.length - 1][3]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(63,45);to=(65,6)]
                out.write("</td>\r\n  <td>&nbsp;</td>\r\n  <td>");

            // end
            // begin [file="/cartview.jsp";from=(65,9);to=(65,43)]
                out.print(goodsObjs[goodsObjs.length - 1][4]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(65,45);to=(66,6)]
                out.write("</td>\r\n  <td>");

            // end
            // begin [file="/cartview.jsp";from=(66,9);to=(66,43)]
                out.print(goodsObjs[goodsObjs.length - 1][5]);
            // end
            // HTML // begin [file="/cartview.jsp";from=(66,45);to=(72,7)]
                out.write("</td>\r\n</tr>\r\n</table>\r\n</form>\r\n</center>\r\n</body>\r\n</html>");

            // end

        } catch (Throwable t) {
            if (out != null && out.getBufferSize() != 0)
                out.clearBuffer();
            if (pageContext != null) pageContext.handlePageException(t);
        } finally {
            if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
        }
    }
}

⌨️ 快捷键说明

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