我试过Struts2 + Hibernate程序。它适用于添加和列表。当我包含在编辑列表中的记录中时,我的过程在textfield中设置了evalue进行编辑。我使用Dao类进行休眠。所以如何做到这一点? 我edit.jsp文件程序包含下面的代码,如何设置Struts2 + Hibernate程序的textfield值
<s:form action="editCustomerAction" >
<s:textfield name="name" label="Name" value='<s:property value="customerName"/>'/>
<s:textarea name="address" label="Address" value="<s:property value="address"/>" cols="20" rows="4" />
<s:submit />
</s:form>
CustomerAction.java
public String editCustomer() throws Exception{
System.out.println("Edit Id:" +customer.getCustomerId());
SessionFactory sessionFactory =
(SessionFactory) ServletActionContext.getServletContext()
.getAttribute(HibernateListener.KEY_NAME);
Session session = sessionFactory.openSession();
customerList = session.createQuery("from Customer where customerId = "+customer.getCustomerId()).list();
return SUCCESS;
}
我知道它很简单的人。但请帮我解决这个问题。提前致谢。
问题是我不明白你想要做的,什么是你的问题什么?? – 2012-01-07 11:54:13
正如xcoder所说的,你不能像这样嵌套JSP标签 - 和XML一样。 – 2012-01-08 15:46:30