package com.alioth.spider.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONArray;
import com.alioth.spider.entity.Image;
import com.alioth.spider.util.SpiderUtil;
public class LoadImagesServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public LoadImagesServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获取传入的页码和类型
String pageNum = request.getParameter("pagenum");
String category = request.getParameter("category");
List<Image> images = SpiderUtil.queryImageList(category, pageNum);
response.setContentType("text/html;charset=utf-8");
//从response中获取输出流
PrintWriter out = response.getWriter();
//进行json字符串格式转换
out.print(JSONArray.toJSONString(images,true));
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
alioth_spider.rar (37个子文件)
alioth_spider
.project 1KB
.settings
.jsdtscope 522B
org.eclipse.wst.common.component 498B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.common.project.facet.core.xml 414B
com.genuitec.eclipse.core.prefs 103B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
WebRoot
css
styles.css 1KB
jquery.lightbox-0.5.css 2KB
WEB-INF
web.xml 738B
lib
jsoup-1.8.1.jar 294KB
fastjson-1.1.15.jar 309KB
classes
com
alioth
spider
servlet
LoadImagesServlet.class 2KB
entity
Image.class 907B
util
SpiderUtil.class 3KB
index.jsp 834B
META-INF
MANIFEST.MF 39B
images.jsp 4KB
images
lightbox-blank.gif 43B
lightbox-btn-close.gif 700B
lightbox-btn-next.gif 812B
Thumbs.db 58KB
pixel.gif 43B
backTop.png 5KB
loding.gif 3KB
backTop1.png 4KB
lightbox-btn-prev.gif 832B
lightbox-ico-loading.gif 4KB
js
blocksit.min.js 2KB
jquery-1.7.2.min.js 93KB
jquery.lightbox-0.5.min.js 10KB
jquery.lazyload.min.js 3KB
src
com
alioth
spider
servlet
LoadImagesServlet.java 2KB
entity
Image.java 484B
util
SpiderUtil.java 2KB
.classpath 1KB
共 37 条
- 1
资源评论
- wys8468162017-12-27重新下载一次
天衡
- 粉丝: 14
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功