pagelink.java

来自「java web开发技术方案宝典」· Java 代码 · 共 45 行

JAVA
45
字号
package com.yxq.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.yxq.bean.DBO;

public class PageLink extends HttpServlet {
	private DBO mydb=new DBO();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List currentlist=new ArrayList();
		HttpSession session=request.getSession();
		
		int currentP=1;
		String strCP=request.getParameter("showpage");
		if(strCP==null||strCP.equals(""))
			strCP="1";
		try{
			currentP=Integer.parseInt(strCP);
		}catch(Exception e){
			currentP=1;
		}
		
		currentlist=mydb.getCurrentList(currentP); 
		session.setAttribute("currentP",Integer.valueOf(currentP));
		session.setAttribute("currentlist",currentlist);		
		session.setAttribute("pageinfo",mydb.getCreatepage().PrintPageInfo());
		session.setAttribute("pagelink",mydb.getCreatepage().PrintPageLink("shop/pagelink?mainPage=gobuy.jsp"));		
		
		RequestDispatcher rd=request.getRequestDispatcher("/shop/preindex");
		rd.forward(request,response);
	}
}

⌨️ 快捷键说明

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