请教!struts的购物车为什么不能添加商品??

ysll830 ysll830 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是shoppingCart的bean
public class ShoppingCart {
private double totalPrice;
private Map<Integer,Line> lines=new HashMap<Integer,Line>();

public void addItem(Line line){
Integer bookId=line.getBook().getId();
if(lines.containsKey(bookId)){
Line oldLine=lines.get(bookId);
int oldQuantity=oldLine.getQuantity();
oldQuantity=+line.getQuantity();

oldLine.setQuantity(oldQuantity);
oldLine.setCost(oldLine.getLineCost());

lines.put(bookId, oldLine);
}else{
line.setCost(line.getLineCost());

lines.put(bookId, line);
}
}
}
jsp里面
<jsp:useBean id="cart" class="org.ysll.model.biz.entity.ShoppingCart" scope="session"></jsp:useBean>
<%
List<Line> lines=new ArrayList<Line>();
Map<Integer,Line>bookMap=cart.getLines();
Set<Integer>key=bookMap.keySet();
Iterator it=key.iterator();


while(it.hasNext()){
Integer i=(Integer)it.next();
Line line=(Line)bookMap.get(i);
lines.add(line);
out.println(line.getBook().getName());
}
%>

<TABLE cellSpacing=0 cellPadding=3 border=0>
<TBODY>
<!-- Header Row -->
<TR bgColor=#cccccc>

<TD noWrap align=middle><FONT size=2><B>书号</B></FONT></TD>
<TD noWrap align=middle><FONT size=2><B>书名</B></FONT></TD>
<TD noWrap align=middle><FONT size=2><B>个数</B></FONT></TD>
<TD noWrap align=middle><FONT size=2><B>价格</B></FONT></TD>
<TD noWrap align=middle><FONT size=2><B>购买总价格</B></FONT></TD>
</TR>

<%for (int i = 0; i < lines.size(); i++) {
Line l = lines.get(i);
%>
<TR bgColor=#ffffff>


<TD ><FONT size=2><B><%=l.getBook().getId()%><BR>
</B></FONT></TD>
<!-- name and description for item -->
<TD ><FONT size=2><B><%=l.getBook().getName()%></B></FONT></TD>

<!-- Qty input box -->
<TD ><FONT size=2><B><%=l.getQuantity()%></B></FONT></TD>


<!-- Unit price for item -->
<TD ><FONT size=2><B><%=l.getBook().getPrice()%><BR>
</B></FONT></TD>

<!-- Extended price for item -->
<TD>
<TABLE cellSpacing=2 cellPadding=3 border=0>
<TBODY>
<TR>
<TD align=right bgColor=#ffcc00><FONT size=2><B><%=l.getCost()%><BR>
</B></FONT></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<%}
%>
请问为什么不能加进去呢??急死我了..
...全文
评论 3
收藏 已收藏
分享
返回顶部
ysll830
智能路由器 684 成员 913 内容