请教!struts的购物车为什么不能添加商品??
这是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>
<%}
%>
请问为什么不能加进去呢??急死我了..