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

📄 showtitleaction.java

📁 这个程序是花了好几十万请人开发的
💻 JAVA
字号:
package struts.action;import java.sql.*;import java.util.*;import javabean.*;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 struts.form.ShowtitleForm;/*调用的javabean:ConnectionPool//初始化缓冲池DBaseLT//为论坛的各种数据库操作而写的类PageNumber//关于分页的处理的类Luntan2DB//表LUNTAN2的封装类 */public class ShowtitleAction extends Action {		public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response)		throws Exception {		ShowtitleForm titleForm=(ShowtitleForm)form;		int pagesize=25;//设置每页能够显示的记录数		Vector vec1=new Vector();		Vector vec2=new Vector();		Vector vecding=new Vector();		Vector vecding1=new Vector();		Vector vecgong=new Vector();		Vector vecgong1=new Vector();//		初始化缓冲池,获得对数据库的连接		ConnectionPool pool=null;		pool=ConnectionPool.getInstance();		Connection con=null;		try		{			con=pool.getConnection();		}		catch(SQLException e){}		DBaseLT DBase=new DBaseLT(con);//为论坛的各种数据库操作而写的类		PageNumber pagenumber=new PageNumber(con);//关于分页的处理的类		String page;        //获得要显示的页面,titleForm中的数据是        //从include/titlecontent.jsp中的表单传过来的		page=titleForm.getPage();		if(page==null || page.length()==0)			page=request.getParameter("page");		if(page==null)			page="1";			String str,str1;		int code;		//当为第一页时,除了要显示普通主题之外的记录,还要显示公告和置顶的主题记录		//否则只显示普通主题记录		if(page.equals("1"))		{			//查询置顶的记录			str1="select * from luntan1 where grant1=2 order by code desc ";			vecding=DBase.getLuntan1DB(1,pagesize,str1);//获得表luntan1的所有置顶记录			if(vecding!=null)			{				int sizeding=vecding.size();				for(int i=0;i<sizeding;i++)				{//获得每条置顶记录的最后一个回复人的用户名和发表时间					Luntan2DB luntan2DB=new Luntan2DB();//表LUNTAN2的封装类					code=((Luntan1DB)vecding.get(i)).getCode();					String lastpub=DBase.getLastPubdate(code);					String lastuuid=DBase.getLastUuid(code);					luntan2DB.setUuid(lastuuid);					luntan2DB.setPubdate(lastpub);					vecding1.add(luntan2DB);				}			}			//查询公告的记录			str1="select * from luntan1 where grant1=3 order by code desc";			vecgong=DBase.getLuntan1DB(1,pagesize,str1);//获得表luntan1的所有公告记录			if(vecgong!=null)			{				int sizegong=vecgong.size();				for(int i=0;i<sizegong;i++)				{//获得每条公告记录的最后一个回复人的用户名和发表时间					Luntan2DB luntan2DB=new Luntan2DB();					code=((Luntan1DB)vecgong.get(i)).getCode();					String lastpub=DBase.getLastPubdate(code);					String lastuuid=DBase.getLastUuid(code);					luntan2DB.setUuid(lastuuid);					luntan2DB.setPubdate(lastpub);					vecgong1.add(luntan2DB);				}			}									}		//查询普通主题的记录		str="select * from luntan1 where grant1=0 or grant1=1 order by code desc";		pagenumber.setPagesize(pagesize);//设置每页能够显示的记录数		pagenumber.setRowcount(str);//设置总行数		pagenumber.setPagecount();//设置总页数		int pagecount=pagenumber.getPagecount();//得到总页数		//如果输入要查询的页数比总页数还大,则只返回总页数的大小		if(Integer.parseInt(page)>pagecount)		{			page=String.valueOf(pagecount);		}		vec1=DBase.getLuntan1DB(Integer.parseInt(page),pagesize,str);//获得要查询的页面的普通主题记录		if(vec1!=null)		{			int size=vec1.size();			for(int i=0;i<size;i++)			{//获得每条记录的最后一个回复人的用户名和发表时间				Luntan2DB luntan2DB=new Luntan2DB();				code=((Luntan1DB)vec1.get(i)).getCode();				String lastpub=DBase.getLastPubdate(code);				String lastuuid=DBase.getLastUuid(code);				luntan2DB.setUuid(lastuuid);				luntan2DB.setPubdate(lastpub);				vec2.add(luntan2DB);			}		}		if(page.equals("1"))		{//如果是第一页,则把置顶和公告的记录传到titlecontent.jsp页面			request.setAttribute("vecding",vecding);			request.setAttribute("vecding1",vecding1);			request.setAttribute("vecgong",vecgong);			request.setAttribute("vecgong1",vecgong1);		}		request.setAttribute("vec1",vec1);		request.setAttribute("vec2",vec2);		request.setAttribute("page",page);		request.setAttribute("pagecount",String.valueOf(pagecount));		titleForm.setPage("1");		HttpSession session=request.getSession();		//解决重复提交的问题		if(session.getAttribute("token")==null)		{			String token="1";			session.setAttribute("token",token);		}		try		{			if(con!=null) 			con.close();		}		catch(SQLException e){}		return(mapping.findForward("success"));	}}

⌨️ 快捷键说明

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