JSP 页面:
<s:iterator value="classes" status="userStatus">
<tr>
<td><s:property value="classTitle" /></td>
<td><s:property value="viewOrder" /></td>
<td><s:property value="createdBy" /></td>
<td><s:date name="createdDate" format="dd-MMM-yyyy"/></td>
<td>
<input type="button" class="btn btn-green5" value="Manage Sections" />
<input type="button" class="btn btn-blue5" value="Edit" />
<input type="button" class="btn btn-red5" value="Delete" />
</td>
</tr>
</s:iterator>
用户逻辑类:
public class UserMasterLogic {
private Session session;
private static SessionFactory factory;
public UserMasterLogic() {
factory = new Configuration().configure().buildSessionFactory();
this.session = factory.openSession();
}
public String getUserIdById(int id) {
UserMaster user = null;
try {
session.beginTransaction();
user = (UserMaster) session.get(Class.class, id);
} catch (HibernateException h) {
System.out.println(h);
}
return user.getUserId();
}
}
现在我想将属性createdBy
值传递给getUserIdById()
方法并在表格行上显示返回值。