[英]Is it common to have for the fields in a form to have its own class?
sample: 样品:
I have 2 tables, department and employees (these 2 table is link via the department_id foreign key in employees). 我有2个表,部门和雇员(这2个表通过雇员中的department_id外键链接)。 and obviously, department has a one-to-many relationship with the employees table.
显然,部门与雇员表之间存在一对多关系。
I need to create a form that has a subset of data from both tables. 我需要创建一个表单,其中包含来自两个表的数据的子集。
These are fields in the web form. 这些是Web表单中的字段。
I'm wondering if creating a new class for these 4 fields is "best practice"? 我想知道为这4个字段创建新类是否是“最佳实践”? Thanks!
谢谢! :)
:)
If you are just returning one of each, you can simply add them to the Model. 如果只返回其中之一,则只需将它们添加到模型中即可。 If you are returning a bunch of "rows" of these things, then I would say it makes more sense to wrap the values in a Bean and pass back a collection of instances of that bean.
如果您要返回一堆“行”,那么我想说将值包装在Bean中并传回该Bean实例的集合更有意义。 It makes it easier to look through them on the view-side.
这样可以更轻松地在视图侧浏览它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.