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

📄 viewutil.java

📁 java数据库操作工具类
💻 JAVA
字号:
package com.baosight.util;

import java.io.IOException;

import javax.servlet.jsp.JspWriter;

public class ViewUtil {
	public static final int DEFAULT_PAGE_LENGTH  =10;
	public static final String ALERT_INSERT_ERROR = "不能新增,请检查数据,确认收汇方式代码是否已经存在!";

	public static void alert(JspWriter outs, String info) throws IOException {
		outs.println("<script>alert(\"" + info + "\");</script>");
	}

	public static String pagination(String form,int count, int page,int pageLength)
			throws IOException {
		int totalPage = count / pageLength;
		if (count % pageLength != 0)
			totalPage++;
		if (page > totalPage)
			page = totalPage;
		if (page < 1)
			page = 1;
		String rt = "第" + page + "页共" + totalPage + "页/" + count + "条记录 ";
		if (page > 1) {
			rt = rt + "<a href='javascript:goPage("+form+"," + (page - 1)
					+ ")'>上一页</a>";
		}
		if (page < totalPage) {
			rt = rt + "<a href='javascript:goPage("+form + "," + (page + 1)
					+ ")'>下一页</a>";
		}

		rt = rt + "转到<input name=\"gotoPage\" type=\"text\" id=\"gotoPage\""
				+ "size=\"2\"><a href=\"javascript:gotoPage('"+form+"')\">跳转</a>";

		rt = rt + "<input type=\"hidden\" name=\"current_page\" value=\""+ page+"\">";
		rt = rt + "<input type=\"hidden\" name=\"rows\" value=\""+ count+"\">";
		rt = rt + "<input type=\"hidden\" name=\"pages\" value=\""+ totalPage+"\">";

		return rt;
	}

	public static String pagination(String form, int count, int page) throws IOException{
		return pagination(form,count, page,DEFAULT_PAGE_LENGTH);
	}

	public static String pagination(String form, int count, String page) throws IOException{
		return pagination(form,count, page,DEFAULT_PAGE_LENGTH);
	}

	public static String pagination(String form, int count, String page,int pageLength) throws IOException{
		if( page.length()==0 ) {
			page = "1";
		}
		int nowPage = new Integer(page).intValue();

//		return pagination(form,count, nowPage,DEFAULT_PAGE_LENGTH);
  return pagination(form,count, nowPage,pageLength);
	}
}

⌨️ 快捷键说明

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