⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchaction.java

📁 一个购物网站
💻 JAVA
字号:
package dataDisposal;

import java.util.*;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SearchAction extends HttpServlet{
     public void doGet(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{		
		HttpSession session=request.getSession(); 
		PrintWriter out=response.getWriter();
		ServletContext application=getServletConfig().getServletContext();
				
		int i=Integer.parseInt((String)request.getParameter("prices_select"));
		String condition=null;
		switch(i){
		case 1: condition = "goodPrice<20"; break;
		case 2: condition = "goodPrice>=20 and  goodPrice<30"; break;		
		case 3:condition = "goodPrice>=30 and  goodPrice<40"; break;
		case 4:condition = "goodPrice>=40 and  goodPrice<50"; break;
		default : break;
		}
		if(condition==null){
			throw new IOException("SearchAction::condition can't be null");
		}
		//在前面必须保证 0<i<=4
		String sql="select * from goodsInfo where " + condition;
		
		ArrayList goodsList=null;
		GoodsListBean goodsListBean = new GoodsListBean();
		
		goodsList = goodsListBean.getList(sql);
		
		session.setAttribute("goodsList",goodsList);			
		//在使用完成后,必须注销掉			
		
		application.getRequestDispatcher("/search.jsp").forward(request,response);
			
	}

	public void doPost(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{		
		doGet(request,response);
	}
	
}

⌨️ 快捷键说明

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