资源简介
使用ajax实现电子商务网站中的购物车系统+源码,希望对你有帮助!
代码片段和文件信息
package org.apache.jsp.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import com.accp.gz.th.zm.client.javabean.*;
public final class CartList_jsp extends org.apache.jasper.runtime.HttpJspbase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
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;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType(“text/html; charset=GBK“);
pageContext = _jspxFactory.getPageContext(this request response
null true 8192 true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write(“\r\n\r\n“);
ArrayList cartlist=(ArrayList)session.getAttribute(“cartlist“);
out.write(“\r\n\r\n\r\n \r\n ript type=\“text/javascript\“ language=\“javascript\“>\r\n\r\n var xmlHttp;\r\n\r\n function delGoods(gid){\r\n\r\n //创建对象\r\n createxmlHttpRequest();\r\n\r\n // 构造地址\r\n var url=\“/GoodsSysModule/cartupdservlet?gid=\“+gid;\r\n\r\n //提交给服务器\r\n xmlHttp.open(\“GET\“urltrue);\r\n xmlHttp.onreadystatechange=callback;\r\n xmlHttp.send(null);\r\n }\r\n\r\n /**\r\n * 方法 1 :创建对象\r\n */\r\n function createxmlHttpRequest() {\r\n if (window.ActiveXobject) {\r\n xmlHttp = new ActiveXobject(\“Microsoft.xmlHTTP\“);\r\n }\r\n else if (window.xmlHttpRequest) {\r\n xmlHttp = new xmlHttpRequest();\r\n }\r\n }\r\n\r\n\r\n /**\r\n * 方法 3 :响应\r\n */\r\n function callback(){\r\n if(xmlHttp.readyState==4){\r\n if(xmlHttp.status==200){\r\n // 在servlet中已经把选中的商品删除掉了所以这里要把本页面中的这条商品也删除\r\n var gid=xmlHttp.responsexml.getElementsByTagName(\“bookid\“)[0].firstChild.data;\r\n var totalprice=xmlHttp.responsexml.getElementsByTagName(\“cartcount\“)[0].firstChild.data;\r\n“);
out.write(“ document.getElementById(gid).removeNode(true);\r\n document.getElementById(\“totalprice\“).innerHTML=\“总价 : \“+totalprice+\“元\“;\r\n }\r\n }\r\n }\r\n\r\n ript>\r\n \r\n\r\n