我使用struts2框架动态获取记录。 例如。 考试1有6个科目。 ExamId 2有8个科目。 ExamId 3有2个科目。 等 但我没有getSubject1(问题)setSubject1()..... getSubjectN()setSubjectN()无动态获取记录
将帖子 现在的问题是我应该如何retreive它wihtout getter和setter方法。我是使用JQuery的JTable 参考:http://www.simplecodestuffs.com/crud-operations-in-struts-2-using-jtable-jquery-plugin-via-ajax/
我Bean类
@Entity
public class SubjectBean
{
@Id
@GeneratedValue
private int SubjectId;
private String paperCode;
int totalNumber;
@OneToMany(cascade=CascadeType.ALL)
private Collection<Subject> subjectList;
private int examId;
//setters and getters of all
}
主题类
@Entity
public class Subject
{
@Id
@GeneratedValue
private int Id;
private String subjectId;
private int capacity;
//setters and getters
}
动作类。
class CrudAction
{
public String insert() throws IOException
{
String examid =(String) httpSession.getAttribute("examId");
Integer examId =Integer.parseInt(examid);
Map<String, String[]> requestParams = request.getParameterMap();
//inserting data using hibernate
return "success";
}
punlic String getAll()
{
// how can i access?
}
}
你能取悦更加清晰。如果有可能添加一些代码,并解释你在哪里发现的困难.. – Babel
请检查编辑。 – gracy
为什么不使用'ArrayList'?在该列表中保留'任何持有数据的Bean类对象。..并创建'ArrayList' getter和setter ..它将在您的JSP中可用。 – Babel