调用数据库数据显示在jsp页面上。为null。 根据typeid来检索数据库里的信息,在页面上显示typeid=1的内容,但是在页面上显示的是Null,求指导,如何正确的显示数据里的信息。 dao:
public interface InformationDao {
public List<Information>searchInformation(int typeid)throws SQLException; daoimpl:
public class InformationDaoImpl implements InformationDao {
@Override
public List<Information> searchInformation(int typeid) throws SQLException {
String sql="select * from information where typeid=?";
List<Information>list=new ArrayList<Information>();
PreparedStatement pstmt=null;
ResultSet rs=null;
Connection conn=ConnDB.getConnection();
try {
pstmt=conn.prepareStatement(sql);
pstmt.setInt(1, typeid);
rs=pstmt.executeQuery();
while (rs.next()) {
Information information=new Information();
information.setInformationid(rs.getRow());
information.setTitle(rs.getString("title"));
information.setContent(rs.getString("content"));
information.setTypeid(rs.getInt("typeid"));
information.setDate(rs.getString("date"));
list.add(information);