Struts 2 - 添加到嵌套集合
所以我有一个学生类,它是我的动作类
import java.util.Vector;
public class Student extends ActionSupport{
private Vector<AcaClass> classes;
public Student(){}
public Vector<Class> getClasses() {
return classes;
}
public void setClasses(Vector<Class> classes) {
this.classes = classes;
}
public void addClass(AcaClass acaClass){
this.classes.add(acaClass)
}
}
,并且我有一个 AcaClass
public class AcaClass {
private Term term;
private String grade;
private String description;
//public
public AcaClass(){}
//Getters and setters for all data members
}
是否可以将一个类添加到学生的类集合中?我觉得我必须提交表单,然后进行一些类型转换才能将表单字段转换为 AcaClass bean。如果可能的话,我可以进入多少级别的集合(即,将一个班级添加到大学集合中的学院集合中的学生集合中)
So I have a student class that is my action class
import java.util.Vector;
public class Student extends ActionSupport{
private Vector<AcaClass> classes;
public Student(){}
public Vector<Class> getClasses() {
return classes;
}
public void setClasses(Vector<Class> classes) {
this.classes = classes;
}
public void addClass(AcaClass acaClass){
this.classes.add(acaClass)
}
}
and I have a AcaClass
public class AcaClass {
private Term term;
private String grade;
private String description;
//public
public AcaClass(){}
//Getters and setters for all data members
}
Is it possible to add a class to to the student's collection of classes? I feel like that I would have to do a form submission and then some type conversion to turn the form fields into the AcaClass bean. If this is possible, how many levels of collections can I go (i.e. Add a class to a collection of students thats in a collection of colleges thats in a collection of universities)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OGNL 将为您进行转换。
看看这个非常相似的问题。 Struts2 - 编辑复合对象
OGNL will do the conversion for you.
See this very similar question. Struts2 - Edit Composite Object