站内搜索:
首页 >> 前端 >> 内容
html页面获取java后台传递的对象(代码教程)

时间:2018/1/23 14:11:09

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;
    }

  • 上一篇:vue省市区三联动下拉选择组件的实现教程
  • 下一篇:jquery的$.ajax()利用json数据类型与php后台交互(代码教程)
  • 返回顶部