JSP显示新闻
2021-02-02 11:15
标签:插入数据 pac pack pos javaee git ack from try 实现效果: 实现步骤: 创建表News并插入数据
导入新闻模板 新建NewsService,提供News类的数据服务 新建ShowNewsListServlet.java,从NewsService中获取所需的数据,并将数据传递给ShowNewsList.jsp来显示 配置web.xml文件 调整模板的内容,将后台主界面index.html中的herf改为ShowNewsListServlet,用以通过Servlet来实现网页信息的动态展示 码云地址:https://gitee.com/xmr123/javaeeservletying/tree/JSP显示新闻 JSP显示新闻 标签:插入数据 pac pack pos javaee git ack from try 原文地址:https://www.cnblogs.com/543123abcxmr/p/13170756.htmlpackage Service;
import Controller.DatabaseOperation;
import Entity.News;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
//提供News类的数据服务
public class NewsService {
public void AddNews(){}
public void DeleteNews(){}
public void UpdateNews(){}
public List
@WebServlet(name = "Controller.ShowNewsListServlet")
public class ShowNewsListServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
NewsService newsService=new NewsService();
try {
List