searchservlet.java

来自「基于jsp的网上书店」· Java 代码 · 共 45 行

JAVA
45
字号
package shop;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public final class SearchServlet extends HttpServlet{ 
	
	public SearchServlet(){
		super();
	}
	
	public void init(ServletConfig config)throws ServletException{
		super.init(config);
	}
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {      
		
		
		HttpSession session = req.getSession();
		if(session==null){
			System.out.println("no session");
			System.exit(1);
			
		}
		
		Integer sortId =(Integer)req.getAttribute("sortId");
		String keyword = (String)req.getParameter("keyword");
		
		String PageForward="SearchMain.jsp?sortId=-1";
		
		
		DB db=new DB();
		shop sp=new shop();
		Vector productList=null;
		try {
			productList=sp.getMatchProducts(db,sortId.intValue(),keyword);
		} catch (Exception e) {
			// TODO 鑷

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?