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()
方法并返回值显示在表格行上。
答案 0 :(得分:0)
如果你想从JSP页面调用一些方法,那么就这样调用它:
<s:property value="getUserIdById(createdBy)" />
<强>更新强>
这样做的正确方法是将UserMasterLogic
注入您的操作类,然后如果您想从JSP调用它:
<s:property value="userMasterLogic.getUserIdById(createdBy)" />