📄 queryproductsaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.gensou.struts.sheji.order.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.gensou.dao.sheji.product.ProductDao;
import com.gensou.struts.sheji.product.form.QueryProductForm;
import com.gensou.util.PagesMax;
/**
* MyEclipse Struts
* Creation date: 01-31-2007
*
* XDoclet definition:
* @struts.action path="/queryproducts" name="queryproductForm" scope="request" validate="true"
* @struts.action-forward name="queryproducts" path="/gjsp/sheji/order/queryProducts.jsp"
*/
public class QueryproductsAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
QueryProductForm queryproductForm = (QueryProductForm) form;// TODO Auto-generated method stub
String way = null;
String term=null;
String pages=request.getParameter("pageS");
int pagei=Integer.parseInt(pages);
String hql;
int maxpage=1;
ProductDao productDao=new ProductDao();
List list=new ArrayList();
try{
way=queryproductForm.getWay();
term=queryproductForm.getTerm();
if(way==null||way.equals("")||term==null||term.equals("")){
way=(String)request.getParameter("way");
term=(String)request.getParameter("term");
if(way==null||way.equals("")||term==null||term.equals("")){
hql="select count(id) from Changpinxinxi";
maxpage=PagesMax.max(hql);
list=productDao.queryproductall(way,term,pagei,maxpage);
}
}else{
hql="select count(id) from Changpinxinxi where "+way+" like '%"+term+"%'";
maxpage=PagesMax.max(hql);
list=productDao.queryproductall(way,term,pagei,maxpage);
}
}catch(NullPointerException e){}
if(list.isEmpty()){
String str="该产品不存在";
request.setAttribute("str", str);
return mapping.findForward("queryproducts");
}else{
request.setAttribute("way",way);
request.setAttribute("term",term);
request.setAttribute("pageS",pagei+"");
request.setAttribute("maxpages",maxpage+"");
request.setAttribute("product_info", list);
return mapping.findForward("queryproducts");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -