Spring-Hibernate:使用相关对象时如何定义默认值
我有一个 Spring 3 MVC 应用程序将 Hibernate 作为 ORM。一切正常。但有一个问题:
我有一个网络界面来创建新对象,比如新客户。每个客户都有一个状态。状态表具有预定义值。 CUSTOMER-Table 有一个 status_id 字段来连接信息。
显示 CUSTOMERS 列表时,我可以访问 CUSTOMER.STATUS 属性并根据 id 获取正确的对象。
但是:如何为新客户定义标准状态?我有一个带有下拉菜单的网络界面。
<form:select path="status">
<form:option value="0" label="- Please Select -" />
<form:options items="${customerStatuses}" itemValue="id" />
</form:select>
这总是显示“请选择”文本,因为该值似乎始终为 0???如何将其更改为我单独选择的标准状态?
I have a Spring 3 MVC app sing Hibernate as ORM. All works fine. But a question:
I have a web interface to create new objects, say a new CUSTOMER. Each CUSTOMER has a STATUS. The STATUS-Table has predefined values. The CUSTOMER-Table has a status_id field to joind the information.
When displaying a list of CUSTOMERS, I can access the CUSTOMER.STATUS property and get the right object baed on the id.
BUT: How can I define a standard status for NEW CUSTOMERS? I have a web interface with a dropdown.
<form:select path="status">
<form:option value="0" label="- Please Select -" />
<form:options items="${customerStatuses}" itemValue="id" />
</form:select>
This always shows the "Please Select" text because it seems like the value is always 0??? How can I change this to my individually selected standard status?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的控制器需要处理这个问题。我会这样做:
事实上,“-请选择-”标签将不再显示,因为您的状态始终已满。
(我希望这次我正确理解了你的问题。)
You controller needs to take care of this. I would do it like this:
As a matter of fact, the "- Please Select -" label will not show anymore because your status is always filled.
(I hope I understood your question correctly this time.)