核心提示:html页面获取java后台传递的对象使用EL表达式在前台el表达式中,获取后台传的实体对象集合的值 例如:th:text=${entity.id}是先通过取实体类的id成员 如果成员是private...
html页面获取java后台传递的对象
使用EL表达式
在前台el表达式中,获取后台传的实体对象集合的值 例如:th:text=${entity.id}
是先通过取实体类的id成员 如果成员是private 继续通过getID()方法取id值
所以entity.id的名称不能随便乱取,要按照id成员的get方法取
前台代码
<th th:text="${ofd.id}">订单编号</th> <th th:text="${ofd.ywType}">业务类型</th> <th th:text="${ofd.orderType}">订单类型</th> <th th:text="${ofd.price}">订单金额</th>
定义的类的部分代码
private int id;//订单编号 private String ywType;//业务类型 private String orderType;//订单类型 private float price;//订单金额 /** 省略其它代码 */ public int getId(){ return this.id; } public String getYwType(){ return this.ywType; } public String getOrderType() { return orderType; } public float getPrice(){ return this.price; }