struts2 jsp获取session属性值

来源:互联网 发布:中国专利文献数据库 编辑:程序博客网 时间:2024/05/27 14:12

action function片段:

public String submit_orders() {// 生成orders实例orders = new ArrayList<Product>();HttpServletRequest request = ServletActionContext.getRequest();Map<String, Object> map = request.getParameterMap();Set<String> set = map.keySet();Iterator<String> it = set.iterator();while(it.hasNext()) {String s = it.next();s = s.substring(1);String[] strs = (String[]) map.get("s" + s);int amount = Integer.valueOf(strs[0]);if(amount == 0) {continue;}Product p = orderService.getProInfo(Integer.valueOf(s));double price = p.getZy_SalePrice();double per_total = price * amount;p.setZy_total(per_total);p.setZy_SaleCount(amount);orders.add(p);}ServletActionContext.getRequest().getSession().setAttribute("orders", orders);return new Constant().SUBMITING;}
jsp片段:

<s:iterator id="row" status="st" value="#session.orders"><tr class="overview"><td class="overview"><s:property value="Zy_ProID" /></td><!-- 产品编号--><td class="overview"><s:property value="Zy_ProName" /></td><!-- 产品名 --><td class="overview"><s:property value="Zy_ProSet" /></td><!-- 产品系列 --><td class="overview"><s:property value="Zy_ProStandard" /></td><!-- 产品系列 --><td class="overview"><s:property value="Zy_SaleCount" /></td><!-- 订货量 --><td class="overview"><s:property value="Zy_SalePrice" /></td><!-- 订货量 --><td class="overview"><s:property value="Zy_total" /></td><!-- 产品库存量 --></tr></s:iterator>




0 0