JSP显示新闻
标签:tac jsp bsp inf for 效果 tps next from
一、建表并初始化数据
二、登陆
2.1 登陆失败提示
2.2 登陆成功显示新闻列表
public class NewsMapperImpl implements NewsMapper {
@Override
public List findAllNewsHref() {
Connection conn = null;
Statement statement = null;
ResultSet rs = null;
List news = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
conn = DBUtil.getConnection();
statement = conn.createStatement();
String sql = "select * from news";
rs = statement.executeQuery(sql);
while (rs.next()) {
News nw = new News(
rs.getInt(1),
rs.getString(2),
rs.getString(3),
rs.getString(4),
sdf.parse(rs.getString(5))
);
news.add(nw);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
return news;
}
}
2.2.1 service层
2.2.2 dao层:
2.2.3 controller层
2.2.4 jsp界面
效果:
码云地址:https://gitee.com/chaserff/J2EE.git
JSP显示新闻
标签:tac jsp bsp inf for 效果 tps next from
原文地址:https://www.cnblogs.com/chaserFF/p/13130332.html
文章来自:
搜素材网的
编程语言模块,转载请注明文章出处。
文章标题:
JSP显示新闻
文章链接:http://soscw.com/index.php/essay/51115.html
评论