📄 cart.jsp
字号:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page import="oracle.otnsamples.util.Utilities" %>
<%--
* @author Neelesh
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the Application : cart.jsp
* Creation/Modification History :
*
* Neelesh 10-Jan-2003 Created
*
* Overview of Application :
* This JSP displays all the cart information to the user - the items that have
* been added to the cart with additional details like price is shown. Also
* an option is provided to remove any item from the cart.
*
--%>
<%@ page language="java" errorPage="../misc/errorHandler.jsp" %>
<SCRIPT>
function validate(action){
var frm = document.forms[1];
var it = frm.items;
var elems ;
if(it.length) {
elems =it;
}else{
elems = new Array();
elems[0] = it;
}
for (i = 0 ; i < elems.length ; ++i) {
eval("qty=frm.quantity"+elems[i].value+".value;");
if( !isInt(qty) ) {
alert("<bean:message key='cart.javascript.quantityerror'/>");
eval("frm.quantity"+elems[i].value+".focus()");
return ;
}
if( parseInt(qty,10) <= 0 ) {
alert("<bean:message key='cart.javascript.zeroquantityerror'/>");
eval("frm.quantity"+elems[i].value+".focus()");
return ;
}
}
if(action == "checkout"){
frm.action='authuserdisplayshippingaddress.do';
}
frm.submit();
}
</SCRIPT>
<%-- Header file. Starts the BODY tag--%>
<TABLE width="100%" border="0" cellspacing="0"
cellpadding="3" bordercolor="#B3B18E" >
<TR>
<TD valign="top" align="left" nowrap>
<%-- Display the message, if any--%>
<DIV align="left" class="SubHeading">
<html:messages id="cartmessage" message="true" property="CartMessage">
<bean:write name="cartmessage"/>
</html:messages>
</DIV>
<%-- If the cart is not empty, display the cart--%>
<logic:notPresent name="cartItems" scope="request">
<SPAN class="BlueText" valign="center">
<center>
<img src="images/info.gif" border="0"><bean:message key="cart.emptymessage"/>
</center>
</SPAN>
</logic:notPresent>
<logic:present name="cartItems" scope="request">
<FORM method="post" name="cartForm" action="updatecart.do">
<input type="hidden" name="referrer" value="<%=request.getAttribute("referrer")%>">
<input type="hidden" name="query" value="<%=request.getAttribute("query")%>">
<TABLE border="1" width="80%" cellpadding="0" cellspacing="0" align="center">
<TR>
<th class="BlueBold"> <bean:message key="cart.productlabel"/> </th>
<th class="BlueBold"> <bean:message key="cart.quantitylabel"/></th>
<th class="BlueBold"> <bean:message key="cart.totalheaderlabel"/></th>
</TR>
<%-- For each item in the cart, display item name, total price, quantity
and a link to remove the item from the cart
--%>
<logic:iterate id="item" indexId="i" name="cartItems" type="oracle.otnsamples.vsm.services.data.CartItem">
<TR>
<TD valign="top" class="BlueText" width="50%"> <bean:write name="item" property="itemName"/>
<BR>
<bean:message key="cart.unitpricelabel"/> <%=Utilities.currencyFormat(item.getUnitPrice(),null)%>
<BR>
<A href="removefromcart.do?itemID=<%=item.getId()%>&login=true&referrer=<%=request.getAttribute("referrer")%>&<%=request.getAttribute("query")%>" class="HeaderLink">
<bean:message key="cart.removefromcartlabel"/></A></TD>
<TD valign="top" align="center" width="15%">
<INPUT type="text" name="quantity<%=item.getId()%>" size="4" class="BlueText"
value="<bean:write name="item" property="quantity"/>" maxlength="4">
<BR>
</TD>
<TD valign="top" align="right" width="15%" class="BlueText">
<%=Utilities.currencyFormat(item.getAmount(),null)%>
<input type="hidden" value="<%=item.getId()%>" name="items">
</TD>
</TR>
</logic:iterate>
</TABLE>
<BR>
<TABLE width="80%" align="center">
<TR>
<TD align="center" nowrap><a href="javascript:validate('update');" border="0"><img
src="<bean:message key="image.update"/>" border= "0"></a>
<a href="javascript:validate('checkout');"><img
src="<bean:message key="image.checkout"/>" border= "0"></a> </TD>
</TR>
</TABLE>
</FORM>
<%-- Total amount, tax , shipping and the sum of all these--%>
<TABLE border="0" cellpadding="3" cellspacing="0" align="center" width="80%">
<TR>
<TD valign="middle" align="right" width="70%" class="BlackText">
<bean:message key="cart.subtotallabel"/>
</TD>
<TD valign="middle" align="right" width="3%"></TD>
<TD valign="middle" align="right" width="10%" class="BlackText">
<bean:write name="subtotal"/>
</TD>
</TR>
<TR>
<TD valign="middle" align="right" width="70%"
class="BlackText"><bean:message key="cart.shippinglabel"/></TD>
<TD valign="middle" align="right" width="3%"></TD>
<TD valign="middle" align="right" width="10%"
class="BlackText"><bean:write name="shippingCharges"/></TD>
</TR>
<TR>
<TD valign="middle" align="right" width="70%"
class="BlackText"><bean:message key="cart.taxlabel"/></TD>
<TD valign="middle" align="right" width="3%" ></TD>
<TD valign="middle" align="right" width="10%"
class="BlackText"><bean:write name="tax"/></TD>
</TR>
<TR>
<TD valign="middle" align="right" width="70%"
class="BlueBold"><bean:message key="cart.totallabel"/></TD>
<TD valign="middle" align="right" width="3%" class="BlueBold"></TD>
<TD valign="middle" align="right" width="10%"
class="BlueBold"><bean:write name="total"/></TD>
</TR>
</TABLE>
</logic:present>
</td>
</tr>
</table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -