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

📄 termqueryfoodaction.java

📁 实现网上订餐系统
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.eatery.food.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eatery.service.FoodInfoService;

/** 
 * MyEclipse Struts
 * Creation date: 06-07-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class TermQueryFoodAction extends Action {
	private FoodInfoService service;
	public FoodInfoService getService() {
		return service;
	}
	public void setService(FoodInfoService service) {
		this.service = service;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		int fstId=Integer.parseInt(request.getParameter("fstId"));
		String foodName=request.getParameter("foodName");
		Double startPrice=0.0;
		Double endPrice=0.0;
		try {
			startPrice = Double.parseDouble(request.getParameter("startPrice"));
			endPrice = Double.parseDouble(request.getParameter("endPrice"));
		} catch (NumberFormatException e) {
		}
		int eid=Integer.parseInt(request.getParameter("eid"));
		String hql="FROM FoodInfo as food WHERE";
		List args=new ArrayList();
		if(fstId!=0){
			hql+=" food.foodSmallType.fstId=? and ";
			args.add(fstId);
		}
		if(!"".equals(foodName)){
			hql+=" food.FName=? and ";
			args.add(foodName);
		}
		if(startPrice!=0.0){
			hql+=" food.FPrice>? and ";
			args.add(startPrice);
		}
		if(endPrice!=0.0){
			hql+=" food.FPrice<? and ";
			args.add(endPrice);
		}
		if(eid!=0){
			hql+=" food.enterpriseInfo.EId=? and ";
			args.add(eid);
		}
		
		hql=hql.substring(0,hql.length()-5);

		
		List list=service.findFoodsByTerm(hql, args);
		
		request.setAttribute("Foods", list);
		
		return mapping.findForward("ok");
	}
}

⌨️ 快捷键说明

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