📄 querybookcontrolpro.java
字号:
package com.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.common.DBaccess.QueryBookProcess;
public class QueryBookControlPro extends HttpServlet {
/**
* Constructor of the object.
*/
public QueryBookControlPro() {
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 {
request.setCharacterEncoding("gb2312");
if(request.getParameter("name").equals("query"))
{
String parameter=request.getParameter("select");
String value=request.getParameter("value");
Vector vv=null;
QueryBookProcess qbp=new QueryBookProcess();
if(parameter.equals("bookName"))
{
vv=qbp.getBookByName("Title",value);
}
if(parameter.equals("author"))
{
vv=qbp.getBookByName("Author",value);
}
if(parameter.equals("isbn"))
{
vv=qbp.getBookByName("ISBN",value);
}
System.out.println(vv.size());
request.setAttribute("bookValue",vv);
//必须封装
request.setAttribute("title","图书查询");
request.setAttribute("URL","/view/QeuryBook.jsp");
RequestDispatcher dis=this.getServletContext().getRequestDispatcher("/index.jsp");
dis.forward(request,response);
}
if(request.getParameter("name").equals("lookUp"))
{
Hashtable hhs=null;
String bookid=request.getParameter("bookid");
QueryBookProcess qbp=new QueryBookProcess();
hhs=qbp.getBookByID(Integer.valueOf(bookid).intValue());
System.out.println(hhs);
request.setAttribute("bookMainInfo",hhs);
//馆藏信息
Hashtable hs=qbp.getBookInfo(Integer.valueOf(bookid).intValue());
request.setAttribute("bookInfo",hs);
request.setAttribute("title","图书详细信息");
request.setAttribute("URL","/view/BookView.jsp");
RequestDispatcher dis=this.getServletContext().getRequestDispatcher("/index.jsp");
dis.forward(request,response);
//
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -