我正在为学校项目开发 Java/Glassfish 4 MVC Web 应用程序,但我不确定如何构建 Controller 类。
这是我到目前为止所尝试过的。
class User{
private string userName;
//the rest of the fields
private Address address; //here is one problem, is this how i should do it or
//or should i put the primary key of the address there.... How should i structure
// the constructor?????
}
我的问题是我应该只将字段放在模型类中还是应该将其留在这里。这里有人建议它是域对象,我想知道 Controller 类的一般结构。
最佳答案
这不是 Controller ,它是模型一部分的域对象。
地址的主键确实应该是Address类中的一个字段。
关于java - 如何在 Java MVC Web 应用程序中构造 Controller 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23854257/