public class ParamOrder { private String orderStr; // 排序字段名字(与返回字段对应) private String orderType; // 排序方式 public String getOrderStr() { return orderStr; } public void setOrderStr(String orderStr) { this.orderStr = orderStr; } public String getOrderType() { return orderType; } public void setOrderType(String orderType) { this.orderType = orderType; } }
public class ParamPage { private int page; // 查询的页码 private int pageSize; // 每页显示的条数 private List<ParamOrder> order; // 排序的list public int getPage() { return page; } public void setPage(int page) { this.page = page; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public List<ParamOrder> getOrder() { return order; } public void setOrder(List<ParamOrder> order) { this.order = order; } }
<if test="paramPage.order!=null"> <foreach collection="paramPage.order" index="index" item="item" open="order by" separator="," close=" "> #{paramPage.order.orderStr} ASC </foreach> </if>
collection就是传过来的集合,item就是集合里的元素,
#{paramPage.order.orderStr}应该换成#{item}
你再试试看
正确,不过在排序这块不能用"#",要作"$"才对
@网络终结者: 为什么不用#而是$呢?#{}不是表示占位符么?${}表示拼接符?