早上好,我遇到了这个问题。我应该用DAO连接数据库(在哪里是一个查询),我应该在JSP中查看与此DAO关联的bean。我实现了这段代码,但是没有任何作用。我用jsp和provajsp方法连接一个bean,然后尝试将jsp和DAO类连接到bean,但真的不知道我在做什么,如果可能的话我需要一点帮助。非常感谢
有机行动
private List<StudentNational> listStudent=new ArrayList<StudentNational>() ;
private List<Bean> empList = new ArrayList<Bean>();
public List<StudentNational> getListStudent() {
return listStudent;
}
public void setListStudent(List<StudentNational> listStudent) {
this.listStudent=listStudent;
}
CLASS ORGANIC SERVICE IMPL
@Override
public List <Bean> provajsp() throws Exception {
List <Bean> result = StudentNationalDAO.provajsp();
Iterator<Bean> it = result.iterator();
Bean obj = null;
String name= obj.getName();
String surname= obj.getSurname();
return StudentNational.provajsp();
CLASS BEAN
private String name;
private String surname;
with getter and setter
STUDENT NATIONAL包含带有字段的表 桌子
CLASSE StudentNationalDAO IMPL
List<StudentNational> result = null;
String sqlNative = " Select * FROM StudentNational";
Query query = getEntityManager().createNativeQuery(sqlNative);
result = query.getResultList();
return result;
和包含用于查看页面的迭代器的JSP。