@RequestMapping(value="/homePage")
public String list(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
Product pro = new Product();
pro.setProductname("草莓");
pro.setSellprice("售价:100");
pro.setMarketprice("300");
pro.setStandard("规格/份");
pro.setIsshow("热销中");
pro.setProducttypeid("苹果");
pro.setDescription("描述:不错哦");
Map<String,String> map = new HashMap<String,String>();
map.put("key1", pro.getProductname());
map.put("key2", pro.getSellprice());
map.put("key3", pro.getMarketprice());
map.put("key4", pro.getStandard());
map.put("key5", pro.getIsshow());
map.put("key6", pro.getProducttypeid());
map.put("key7", pro.getDescription());
request.setAttribute("map", map);
System.out.println("进入List()方法。。。");
System.out.println(map.toString());
return "/product/homePage";
}
这是我后台的代码,
<c:forEach items="${map}" var="item">
key值: value="${item.key}"
value值: value="${item.value}"
<br />
<%-- ${item.value} --%>
<li class="public-li" >
<a class="img-link" href="user/fruitxiangqing.html">
<img src="${ctxStatic}/img/caomei.png"/>
</a>
<p class="name">${item.value}</p>
<p class="money">¥<span></span>/<span>份</span></p>
<p class="moneys">市场价:¥<span>8.99</span>/<span>份</span></p>
</li>
<%-- <li class="public-li">
<a href="">
<img src=" ${ctxStatic}/img/nimgmeng.png"/>
</a>
<p class="name">四川黄柠檬</p>
<p class="money">¥3.99/份</p>
<p class="moneys">市场价:¥8.0/份</p>
</li> --%>
</ul>
</c:forEach>
这是前段的页面,如果${item.value}只获取一个最后的值,求大神带,如何获取每一个key的值
你直接把Product 这个类放进去救可以了,然后“.”他的属性就可以取值,没必要这么麻烦啊