📄 shouaction.java
字号:
package com.ascenttech.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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 org.apache.struts.actions.DispatchAction;
import com.ascenttech.hib.help.FenBean;
import com.ascenttech.hib.help.PageBean;
import com.ascenttech.hib.po.MessageIn;
import com.ascenttech.hib.po.MessageIn1;
import com.ascenttech.hib.po.SucessBean;
import com.ascenttech.shi.LuanMa;
import com.ascenttech.struts.form.ShouForm;
public class ShouAction extends Action {
private String sc;
private String ss;
private String subport;
public ShouAction() {
super();
// TODO Auto-generated constructor stub
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
ShouForm sf=(ShouForm)form;
//验证用
HttpSession session=request.getSession();
SucessBean sb=(SucessBean)session.getAttribute("sucess");
subport=sb.getSubport();
//符合查询用
String cha=(String)session.getAttribute("s1");
String nn=(String)session.getAttribute("v");
String mm=(String)session.getAttribute("v1");
//页面提交当前页面数用
String f=(String)request.getParameter("dangpage");
Integer f1 = new Integer(0);
Integer f2 = new Integer(1);
if(cha==null){
// 查询总记录数用
sc="select count(*)from TMessageIn as t where t.subport='"
+ subport + "'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
//查询结果用
ss="from TMessageIn as t where t.subport='"
+ subport + "'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
}
//验证提交按钮
String s=request.getParameter("action");
if(s!=null){
LuanMa lm=new LuanMa();
String s1=lm.changeCode(s);
if(s1.equals("查询")){
String v=sf.getSelect1();
String v1=sf.getSelect2();
session.setAttribute("v",v);
if(v1!=null){
session.setAttribute("v1",v1);
}
session.setAttribute("s1",s1);
if(v!=null&v1!=null){
getSelect(v,v1);
//执行重新查找
f=null;
cha=null;
}
if(v!=null){
getSelect(v);
//执行重新查找
f=null;
cha=null;
}
}
if(s1.equals("删除")){
//接受删除id 数组
String id[]=request.getParameterValues("id");
MessageIn1 mi1=new MessageIn1();
String deleteok=mi1.delete(id);
if(deleteok==null){
return mapping.findForward("false");
}
if(deleteok.equals("ok")){
f=null;
cha=null;
}
if(deleteok.equals("no")){
return mapping.findForward("false");
}
}
}
//复合查询调用
if(cha!=null){
if(nn!=null&mm!=null){
getSelect(nn,mm);
session.setAttribute("v",nn);
session.setAttribute("v1",mm);
session.setAttribute("s1",cha);
}
if(nn!=null&mm==null){
getSelect(nn);
session.setAttribute("v",nn);
session.setAttribute("s1",cha);
}
}
int i;
if(f==null){
i=1;
}else{ i=Integer.parseInt(f);}
//得到数据并转发到jsp页面
MessageIn1 mi=new MessageIn1(subport,sc);
PageBean p=mi.select1(i,ss);
session.setAttribute("p",p);
return mapping.findForward("sucess");
}
public void getSelect(String v,String v1){
Integer f1 = new Integer(0);
Integer f2 = new Integer(1);
if(v.equals("cell")&&v1!=null){
sc="select count(*)from TMessageIn as t where t.subport='"
+ subport + "'and t.cell='"+v1+"'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
ss="from TMessageIn as t where t.subport='"
+ subport + "'and t.cell='"+v1+"'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
}
}
public void getSelect(String v){
Integer f1 = new Integer(0);
Integer f2 = new Integer(1);
if(v.equals("3")){
sc="select count(*)from TMessageIn as t where t.subport='"
+ subport + "'and t.flag=" + f2;
ss="from TMessageIn as t where t.subport='"
+ subport + "'and t.flag=" + f2;
}
if(v.equals("4")){
sc="select count(*)from TMessageIn as t where t.subport='"
+ subport + "'and t.flag=" + f1;
ss="from TMessageIn as t where t.subport='"
+ subport + "'and t.flag=" + f1;
}
if(v.equals("2")){
sc="select count(*)from TMessageIn as t where t.subport='"
+ subport + "'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
//查询结果用
ss="from TMessageIn as t where t.subport='"
+ subport + "'and (t.flag='" + f1 + "' or t.flag='"
+ f2 + "')";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -