📄 downlistaction.java
字号:
package com.comingnet.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.db.DBOperator;
import com.db.page;
import com.opensymphony.xwork2.ActionSupport;
public class DownListAction extends ActionSupport {
List downlist=null;
private String pageStr; //分页字符串
private String pageno; //当前页
private int pagecount=0; //总记录数
private int rownum=15; //每页记录数
private int pagerow=10; //显示多少页
private int xxbh=0;
public int getXxbh() {
return xxbh;
}
public void setXxbh(int xxbh) {
this.xxbh = xxbh;
}
public int getPagecount() {
return pagecount;
}
public void setPagecount(int pagecount) {
this.pagecount = pagecount;
}
public String getPageno() {
return pageno;
}
public void setPageno(String pageno) {
this.pageno=pageno;
}
public String getPageStr() {
return pageStr;
}
public void setPageStr(String pageStr) {
this.pageStr = pageStr;
}
public List getDownlist() {
return downlist;
}
public void setDownlist(List downlist) {
this.downlist = downlist;
}
public String execute()
{
String pageno1=getPageno(); //得到当前页
if(pageno1==null)
pageno1="1";
ArrayList list=null;
ArrayList list0=null;
ArrayList list1=null;
ArrayList list2=null;
String flag;
List newlist=new ArrayList();
DBOperator dbop=new DBOperator();
try
{
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
setXxbh(Integer.parseInt(session.getAttribute("xxbh").toString()));
System.out.println( "select count(*) from m_resource where xxbh="+getXxbh());
list0=dbop.ExecuteSelect(false, "select count(*) from m_resource where xxbh="+getXxbh());
if(list0.size()>0){
System.out.println(((ArrayList)list0.get(0)).get(0).toString());
pagecount=Integer.parseInt(((ArrayList)list0.get(0)).get(0).toString());
}
setPagecount(pagecount); //向前台传回总记录数
//System.out.println("xxbh-->"+xxbh);
page page1=new page();
page1.setPageString(pagecount,rownum,Integer.parseInt(pageno1),pagerow,"");
String pageStr=page1.getPageString();
setPageStr(pageStr); //设置分页的字符串
int cupage=Integer.parseInt(pageno1)-1;
String sqlStr="select top "+rownum+" zyym ,zybm,zylj,scrm,CONVERT(varchar,scsj,120) as scsj,zybt,zylb from m_resource where xxbh="+getXxbh()+" and ( zyid not in (select top "+cupage*15+" zyid from m_resource order by zyid DESC)) order by zyid DESC";
System.out.println("sqlStr-->"+sqlStr);
String path="",filename="";
float f=0;
list1=dbop.ExecuteSelect(true, sqlStr);
String name="";
String nameStr="zy_xh";
int j=0;
HashMap row=null;
list2=(ArrayList) list1.get(0);
for(int i=1;i<list1.size();i++){
list=(ArrayList) list1.get(i) ;
j++;
row=new HashMap();
path=list.get(2).toString();
filename=list.get(1).toString();
System.out.println(path+"\\"+filename);
java.io.File file=new java.io.File(path+"\\"+filename);
f=file.length()/1024;
for(int k=0;k<list2.size();k++)
{
name=list2.get(k).toString();
row.put(nameStr,""+j);
row.put(name.toLowerCase(),list.get(k).toString());
}
row.put(nameStr,""+j);
row.put("zydx", f) ;
newlist.add(row);
}
setDownlist(newlist); //此处不能利用getList1(),get方法是获取从页面传过来的值
flag=SUCCESS;
}catch(Exception e)
{
flag=ERROR;
}
// System.out.println("flag-->"+flag);
return flag ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -