You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.5 KiB
39 lines
1.5 KiB
package WeChat;
|
|
|
|
import org.json.simple.JSONArray;
|
|
import org.json.simple.JSONObject;
|
|
|
|
import javax.servlet.ServletContext;
|
|
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 java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
import java.sql.ResultSet;
|
|
import java.sql.Statement;
|
|
import java.util.HashMap;
|
|
|
|
// 首先明确我们这个目的是目标页面的分类功能,根据用户所需要返回所有该类别的图书
|
|
@WebServlet(name = "Classify", urlPatterns = {"/Classify.do"}, loadOnStartup = 2)
|
|
public class Classify extends HttpServlet {
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
if(Authentication.islegal(request)){
|
|
String booktype = request.getParameter("booktype");
|
|
// 防止sql注入
|
|
if(sqlfilter.isNumber(booktype)) {
|
|
String sql = "select * from Book where Type = " + booktype;
|
|
HashMap<String,String> names = new HashMap<>();
|
|
names.put("BookID","BookID");
|
|
names.put("BookName","BookName");
|
|
GetJson.Getinfo(request,response,sql,names);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
doPost(request,response);
|
|
}
|
|
}
|