ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
上一节中,我们已经新建了Klass实体,但没有增加teacherId字段,本节中,我们增加teacherId字段,并增加setGet方法。 # 实体Klass ``` package com.mengyunzhi.javaee.entity; public class Klass { ... private Long teacherId; public Long getTeacherId() { return teacherId; } public void setTeacherId(Long teacherId) { this.teacherId = teacherId; } ... ``` # 新建触发器: klass/GetAction ``` package com.mengyunzhi.javaee.action.klass; import com.mengyunzhi.javaee.action.Action; import com.mengyunzhi.javaee.entity.Klass; public class GetAction extends Action{ private static final long serialVersionUID = 1L; private Long id; private Klass klass; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Klass getKlass() { return klass; } public void setKlass(Klass klass) { this.klass = klass; } public String execute() { this.klass = new Klass(); this.klass.setId(this.id); this.klass.setName("一一级"); this.klass.setTeacherId(1L); return SUCCESS; } } ``` 测试: ![./image/4.3.1.png](./image/4.3.1.png)