package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import bean.paper;
import dao.dao;
/**
* Servlet implementation class findpaper
*/
@WebServlet("/findpaper")
public class findpaper extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public findpaper() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
dao p=new dao();
String id=request.getParameter("id");
String name=request.getParameter("name");
String writer=request.getParameter("writer");
String time=request.getParameter("time");
String keywords=request.getParameter("keywords");
// System.out.println(id+time+name+writer+keywords);
PrintWriter out=response.getWriter();
String json="{}";
try {
List<paper> list=p.findpaper(id, name, writer, time, keywords);
ObjectMapper om=new ObjectMapper();
json=om.writeValueAsString(list);
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
out.println(json);
out.flush();
out.close();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}