显示网站首页的广告图片Slide滚动切换(有数据库)
博客分类: JavaScript
JavaScript .
Java代码 复制代码 收藏代码
1.package com.org;
2.
3.import java.io.IOException;
4.import java.io.PrintWriter;
5.import java.util.List;
6.
7.import javax.servlet.ServletException;
8.import javax.servlet.http.HttpServlet;
9.import javax.servlet.http.HttpServletRequest;
10.import javax.servlet.http.HttpServletResponse;
11.
12.import net.sf.json.JSONArray;
13.
14.import com.org.model.Advert;
15.
16./***
17. *@Author:liangjilong
18. *@Date:2014-5-15
19. *@Version:1.0
20. *@descript:
21. *显示网站首页的广告图片Slide滚动切换
22. */
23.public class SlideServlet extends HttpServlet {
24.
25.
26. public void doGet(HttpServletRequest request, HttpServletResponse response)
27. throws ServletException, IOException {
28. this.doPost(request, response);
29. }
30.
31.
32. public void doPost(HttpServletRequest request, HttpServletResponse response)
33. throws ServletException, IOException {
34. request.setCharacterEncoding("utf-8");
35. response.setContentType("text/html");
36. response.setCharacterEncoding("utf-8");
37.
38. PrintWriter out = response.getWriter();
39.
40. AdvertDao adverDao=new AdvertDao();
41.
42. List<Advert> list=adverDao.getAdverts();
43.
44. out.write(JSONArray.fromObject(list).toString());//把数据转换成json数组
45.
46. out.flush();
47. out.close();
48. }
49.
50.}
http://download.csdn.net/detail/jilongliang/7350237
查看图片附件
博客分类: JavaScript
JavaScript .
Java代码 复制代码 收藏代码
1.package com.org;
2.
3.import java.io.IOException;
4.import java.io.PrintWriter;
5.import java.util.List;
6.
7.import javax.servlet.ServletException;
8.import javax.servlet.http.HttpServlet;
9.import javax.servlet.http.HttpServletRequest;
10.import javax.servlet.http.HttpServletResponse;
11.
12.import net.sf.json.JSONArray;
13.
14.import com.org.model.Advert;
15.
16./***
17. *@Author:liangjilong
18. *@Date:2014-5-15
19. *@Version:1.0
20. *@descript:
21. *显示网站首页的广告图片Slide滚动切换
22. */
23.public class SlideServlet extends HttpServlet {
24.
25.
26. public void doGet(HttpServletRequest request, HttpServletResponse response)
27. throws ServletException, IOException {
28. this.doPost(request, response);
29. }
30.
31.
32. public void doPost(HttpServletRequest request, HttpServletResponse response)
33. throws ServletException, IOException {
34. request.setCharacterEncoding("utf-8");
35. response.setContentType("text/html");
36. response.setCharacterEncoding("utf-8");
37.
38. PrintWriter out = response.getWriter();
39.
40. AdvertDao adverDao=new AdvertDao();
41.
42. List<Advert> list=adverDao.getAdverts();
43.
44. out.write(JSONArray.fromObject(list).toString());//把数据转换成json数组
45.
46. out.flush();
47. out.close();
48. }
49.
50.}
http://download.csdn.net/detail/jilongliang/7350237
查看图片附件