📄 product_list.jsp
字号:
<%@page contentType="text/html;charset=utf-8"%>
<%@include file="common.jsp"%>
<script type="text/javascript">
var xmlHttp = null;
function init() {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
function addLineItem(id) {
if(xmlHttp==null) {
init();
}
var url = "addLineItem.do?id="+id;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=addLineItemCallback;
xmlHttp.send(null);
}
function addLineItemCallback() {
if(xmlHttp.readyState==4) {
var b = xmlHttp.responseText;
if(b=="true") {
alert("成功加入购物车");
} else {
alert("请先登录");
}
}
}
</script>
<p id="whereami">
</p>
<h1>
商品列表
</h1>
<logic:iterate id="product" name="productList">
<p>
<strong><bean:write name="product" property="name" /> <bean:write
name="product" property="price" format="(¥#.##)" /> </strong>
</p>
<table width="100%" class="table">
<tr>
<td width="15%" rowspan="6">
<img src="<%=request.getContextPath()%>/res/${product.id}.jpg"
class="img_left" alt="Picture inside a parragraph" />
</td>
<td width="25%">
<strong>编号:</strong>
<bean:write name="product" property="id" />
</td>
<td rowspan="6" align="left" valign="top">
<strong>描述:</strong>
<bean:write name="product" property="description" />
</td>
</tr>
<tr>
<td>
<strong>名称:</strong>
<bean:write name="product" property="name" />
</td>
</tr>
<tr>
<td>
<strong>定价:</strong>
<bean:write name="product" property="price" format="¥#.##" />
</td>
</tr>
<tr>
<td>
<input type="submit" class="button" value="加入购物车" onClick='addLineItem("${product.id}");'/>
</td>
</tr>
</table>
<hr />
</logic:iterate>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -