//实体类新闻public class Easybuy_news { /** * 编号 */ private int en_id; /** * 标题 */ private String en_title; /** * 内容 */ private String en_content; /** * 录入时间 */ private String en_create_time; public int getEn_id() { return en_id; } public void setEn_id(int enId) { en_id = enId; } public String getEn_title() { return en_title; } public void setEn_title(String enTitle) { en_title = enTitle; } public String getEn_content() { return en_content; } public void setEn_content(String enContent) { en_content = enContent; } public String getEn_create_time() { return en_create_time; } public void setEn_create_time(String enCreateTime) { en_create_time = enCreateTime; } public Easybuy_news() { // TODO Auto-generated constructor stub } public Easybuy_news(int enId, String enTitle, String enContent, String enCreateTime) { super(); en_id = enId; en_title = enTitle; en_content = enContent; en_create_time = enCreateTime; } }//servlet类public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Easybuy_newsdao dao=new Easybuy_newsdaoimpl(); Easybuy_news news=new Easybuy_news(); List<Easybuy_news> list=dao.findtitle(); request.setAttribute("list", list); request.getRequestDispatcher("New.jsp").forward(request, response); //response.sendRedirect(contextPath+"New.jsp"); out.flush(); out.close(); }//jsp页面<script type="text/javascript"> $(function(){ function intinews(){//使用ajax技术获取新闻列表数据 $.ajax({ "url" :"NewServlet", "type" :"post", "dataType" :"json", "success" :preosn }); } function preosn(data){ var $newlist=$("#news").empty(); for(var i=0;i<data.length;){ $newlist.append(data[i].en_title+"<span>内容:"+data[i].en_content+"</span>") } } intinews();//执行新闻列表初始化工作 }); </script> </head> <body> <div id="news"> </div> </body>我这边运行了但它不报错错,可就是在页面上没有加载出来,不知懂怎么回事了
1 回答
- 1 回答
- 2 关注
- 2160 浏览
添加回答
举报
0/150
提交
取消