src/com/yxq/action/InfoAction.java

(开头部分) 10KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.yxq.action;

import java.io.UnsupportedEncodingException;
import java.util.List;

import com.yxq.actionSuper.InfoSuperAction;
import com.yxq.dao.OpDB;
import com.yxq.model.CreatePage;
import com.yxq.tools.DoString;

public class InfoAction extends InfoSuperAction {	
	public String ListShow(){
		request.setAttribute("mainPage","/pages/show/listshow.jsp");	
		
		String infoType=request.getParameter("infoType");
		Object[] params={infoType};
		String sqlPayfor="SELECT * FROM tb_info WHERE (info_type = ?) AND (info_state='1') AND (info_payfor = '1') ORDER BY info_date DESC";
		
		OpDB myOp=new OpDB();
		
		/* 获取所有的付费信息 */
		List onepayforlist=myOp.OpListShow(sqlPayfor, params);				//获取所有付费信息
		request.setAttribute("onepayforlist",onepayforlist);
        
		/* 获取当前页要显示的免费信息 */
		String sqlFreeAll="SELECT * FROM tb_info WHERE (info_type = ?) AND (info_state='1') AND (info_payfor = '0') ORDER BY info_date DESC";		
		String sqlFreeSub="";
		int perR=3;
		String strCurrentP=request.getParameter("showpage");
		String gowhich="info_ListShow.action?infoType="+infoType;
		CreatePage createPage=myOp.OpCreatePage(sqlFreeAll, params,perR,strCurrentP,gowhich);			//调用OpDB类中的OpCreatePage()方法计算出总记录数、总页数,并且设置当前页码,这些信息都封装到了createPage对象中
		
		int top1=createPage.getPerR();
		int currentP=createPage.getCurrentP();		
		if(currentP==1){     		//设置显示第1页信息的SQL语句
			sqlFreeSub="SELECT * FROM tb_info WHERE (info_type = ?) AND (info_state = '1') AND (info_payfor = '0') ORDER BY info_date DESC limit 0,"+top1;
		}
		else{						//设置显示除第1页外,其他指定页码信息的SQl语句
			int top2=(currentP-1)*top1;
			sqlFreeSub="SELECT  * FROM tb_info i WHERE (info_type = ?) AND (info_state = '1') AND (info_payfor = '0') AND (info_date < (SELECT MIN(info_date) FROM (SELECT TOP "+top2+" (info_date) FROM tb_info WHERE (info_type = i.info_type) AND (info_state = '1') AND (info_payfor = '0') ORDER BY info_date DESC) AS mindate)) ORDER BY info_date DESC limit 0,"+top1;
//			sqlFreeSub="SELECT TOP "+top1+" * FROM tb_info i WHERE (info_type = ?) AND (info_state = '1') AND (info_payfor = '0') AND (info_date NOT IN (SELECT TOP "+top2+" info_date FROM tb_info WHERE (info_type = i.info_type) AND (info_state = '1') AND (info_payfor = '0') ORDER BY info_date DESC)) ORDER BY info_date DESC";         //另一种实现分页查询的SQL语句
		}
		
		List onefreelist=myOp.OpListShow(sqlFreeSub, params);				//获取免费信息,信息数量由createPage.setPerR(int PerR)方法指定		
		request.setAttribute("onefreelist",onefreelist);
		request.setAttribute("createpage", createPage);

		return SUCCESS;
	}
	
	public String SingleShow(){
		request.setAttribute("mainPage","/pages/show/singleshow.jsp");
		
		String id=request.getParameter("id");
		String sql="SELECT * FROM tb_info WHERE (id = ?)";
		Object[] params={id};

		OpDB myOp=new OpDB();
		infoSingle=myOp.OpSingleShow(sql, params);
		if(infoSingle==null){
后面还有 229 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。