DC00022基于ssm高校社团管理系统web社团管理系统java web+MySQL项目web程序设计

1、项目功能演示

DC00022基于ssm高校社团管理系统web社团管理系统java web项目MySQL

2、项目功能描述

 社团管理系统分为普通用户、管理员

2.1 普通用户功能

01 系统登录、系统注册
02 系统首页、新闻公告、规章制度、社团活动、互动交流
03 修改密码
04 个人信息修改
05 我的社团活动
06 申请物资
07 我的申请


2.2 管理员功能

01 系统登录、密码修改
02 管理员信息管理:管理员信息新增、修改、删除、查看
03 社团用户信息管理:社团用户信息查询、社团用户账号锁定、用户信息删除
04 网站栏目信息管理:网站栏目信息新增、修改、删除、查询
05 网站内容信息管理:网站内容新增、修改、删除、查询
06 社团活动信息管理:社团活动新增、修改、删除、查询、提前结束
07 申请类型信息管理:申请类型信息新增、修改、删除、查询
08 用户申请信息管理:申请信息查询、申请信息统计、申请信息删除
09 活动报名信息管理:报名信息确认、删除、查询
10 留言交流信息管理:留言交流信息查询、删除、留言回复信息查询、删除

3、项目运行截图


 

4、项目核心代码

4.1  web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<!-- 统一编码:项目用于解决中文乱码 -->

	<filter>
		<filter-name>encoding</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>utf-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
	<filter-name>encoding</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- 配置*控制器 -->
	<!--
	说明: *控制器在初始化时将解析/WEB-INF/springmvc配置文件; springmvc配置文件的名称命名时:
	*控制器的name-servlet.xml
	-->
	<servlet>
		<servlet-name>springmvc</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:springmvc-servlet.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>springmvc</servlet-name>
		<url-pattern>*.action</url-pattern>
	</servlet-mapping>
</web-app>

 4.2 Springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/context 
	http://www.springframework.org/schema/context/spring-context.xsd 
	http://www.springframework.org/schema/mvc 
	http://www.springframework.org/schema/mvc/spring-mvc.xsd 
	http://www.springframework.org/schema/aop 
	http://www.springframework.org/schema/aop/spring-aop.xsd 
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx.xsd">

  <!-- 启用自动扫描 -->
  <context:component-scan base-package="com"></context:component-scan>
  <!-- 启用springmvc相关Annotation的处理器 -->
  <mvc:annotation-driven />

  <!-- 采用注释的方式配置bean -->
  <context:annotation-config />
  <!--proxy-target-class="true"强制使用cglib代理 如果为false则spring会自动选择 -->
  <aop:aspectj-autoproxy proxy-target-class="true" />

  <!-- 配置dbcp数据源 -->
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.gjt.mm.mysql.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3305/ssm_stglxt?useUnicode=true&amp;characterEncoding=UTF8" />
    <property name="username" value="root" />
    <property name="password" value="root" />
    <!-- 队列中的最小等待数 -->
    <property name="minIdle" value="1"></property>
    <!-- 队列中的最大等待数 -->
    <property name="maxIdle" value="5"></property>
    <!-- 最长等待时间,单位毫秒 -->
    <property name="maxWait" value="3000"></property>
    <!-- 最大活跃数 -->
    <property name="maxActive" value="5"></property>
    <property name="initialSize" value="3"></property>
  </bean>

  <!-- 配置mybitasSqlSessionFactoryBean -->
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="configLocation" value="classpath:mybatis.xml"></property>
    <!-- 扫描entity包 使用别名 -->
    <property name="typeAliasesPackage" value="com.entity" />
  </bean>

  <!-- 配置扫描DAO接口包,动态实现DAO接口,注入到spring容器中 -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 注入sqlSessionFactory -->
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    <!-- 给出需要扫描DAO接口包 -->
    <property name="basePackage" value="com.dao" />
  </bean>

  <!-- 配置SqlSessionTemplate -->
  <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
    <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
  </bean>

  <!-- 事务配置 -->
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>
  <!-- 使用annotation注解方式配置事务 -->
  <tx:annotation-driven transaction-manager="transactionManager" />

  <!-- 定义跳转的文件的前后缀 ,视图模式配置 -->
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <!-- 这里的配置是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->
    <property name="prefix" value="/" />
    <property name="suffix" value=".jsp" />
  </bean>

  <!-- 支持上传文件 -->
  <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="104857600" />
    <property name="maxInMemorySize" value="4096" />
    <property name="defaultEncoding" value="UTF-8"></property>
  </bean>

</beans>

4.3 日期处理类

package com.util;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Random;

public class VeDate {

	public static double getDouble(double num) {
		DecimalFormat df2 = new DecimalFormat("#.00");
		return Double.parseDouble(df2.format(num));
	}

	public static String getStringDouble(double num) {
		DecimalFormat df2 = new DecimalFormat("#.00");
		return df2.format(num);
	}

	public static Date getNowDate() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		ParsePosition pos = new ParsePosition(8);
		Date currentTime_2 = formatter.parse(dateString, pos);
		return currentTime_2;
	}

	public static Date getNowDateShort() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		String dateString = formatter.format(currentTime);
		ParsePosition pos = new ParsePosition(8);
		Date currentTime_2 = formatter.parse(dateString, pos);
		return currentTime_2;
	}

	public static String getStringDate() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getStringDatex() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getStringId() {
		Random rand = new Random();
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		String dateString = formatter.format(currentTime);
		return dateString + (rand.nextInt(900) + 100);
	}

	public static String getStringDateShort() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getStringTimeShort() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getYear() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getTimeShort() {
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
		Date currentTime = new Date();
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static Date strToDateLong(String strDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(strDate, pos);
		return strtodate;
	}

	public static String dateToStrLong(java.util.Date dateDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(dateDate);
		return dateString;
	}

	public static String dateToStr(java.util.Date dateDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		String dateString = formatter.format(dateDate);
		return dateString;
	}

	public static Date strToDate(String strDate) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(strDate, pos);
		return strtodate;
	}

	public static Date getNow() {
		Date currentTime = new Date();
		return currentTime;
	}

	public static Date getLastDate(long day) {
		Date date = new Date();
		long date_3_hm = date.getTime() - 3600000 * 34 * day;
		Date date_3_hm_date = new Date(date_3_hm);
		return date_3_hm_date;
	}

	public static String getStringToday() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd HHmmss");
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getHour() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		String hour;
		hour = dateString.substring(11, 13);
		return hour;
	}

	public static String getTime() {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dateString = formatter.format(currentTime);
		String min;
		min = dateString.substring(14, 16);
		return min;
	}

	public static String getUserDate(String sformat) {
		Date currentTime = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat(sformat);
		String dateString = formatter.format(currentTime);
		return dateString;
	}

	public static String getTwoHour(String st1, String st2) {
		String[] kk = null;
		String[] jj = null;
		kk = st1.split(":");
		jj = st2.split(":");
		if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0]))
			return "0";
		else {
			double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;
			double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;
			if ((y - u) > 0)
				return y - u + "";
			else
				return "0";
		}
	}

	public static String getTwoDay(String sj1, String sj2) {
		SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
		long day = 0;
		try {
			java.util.Date date = myFormatter.parse(sj1);
			java.util.Date mydate = myFormatter.parse(sj2);
			day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
		} catch (Exception e) {
			return "";
		}
		return day + "";
	}

	public static String getPreTime(String sj1, String jj) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String mydate1 = "";
		try {
			Date date1 = format.parse(sj1);
			long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
			date1.setTime(Time * 1000);
			mydate1 = format.format(date1);
		} catch (Exception e) {
		}
		return mydate1;
	}

	public static String getNextDay(String nowdate, String delay) {
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
			String mdate = "";
			Date d = strToDate(nowdate);
			long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;
			d.setTime(myTime * 1000);
			mdate = format.format(d);
			return mdate;
		} catch (Exception e) {
			return "";
		}
	}

	public static boolean isLeapYear(String ddate) {

		Date d = strToDate(ddate);
		GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
		gc.setTime(d);
		int year = gc.get(Calendar.YEAR);
		if ((year % 400) == 0)
			return true;
		else if ((year % 4) == 0) {
			if ((year % 100) == 0)
				return false;
			else
				return true;
		} else
			return false;
	}

	public static String getEDate(String str) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		ParsePosition pos = new ParsePosition(0);
		Date strtodate = formatter.parse(str, pos);
		String j = strtodate.toString();
		String[] k = j.split(" ");
		return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);
	}

	public static String getEndDateOfMonth(String dat) {// yyyy-MM-dd
		String str = dat.substring(0, 8);
		String month = dat.substring(5, 7);
		int mon = Integer.parseInt(month);
		if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12) {
			str += "31";
		} else if (mon == 4 || mon == 6 || mon == 9 || mon == 11) {
			str += "30";
		} else {
			if (isLeapYear(dat)) {
				str += "29";
			} else {
				str += "28";
			}
		}
		return str;
	}

	public static boolean isSameWeekDates(Date date1, Date date2) {
		Calendar cal1 = Calendar.getInstance();
		Calendar cal2 = Calendar.getInstance();
		cal1.setTime(date1);
		cal2.setTime(date2);
		int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
		if (0 == subYear) {
			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		} else if (1 == subYear && 11 == cal2.get(Calendar.MONTH)) {

			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		} else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH)) {
			if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
				return true;
		}
		return false;
	}

	public static String getSeqWeek() {
		Calendar c = Calendar.getInstance(Locale.CHINA);
		String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
		if (week.length() == 1)
			week = "0" + week;
		String year = Integer.toString(c.get(Calendar.YEAR));
		return year + week;
	}

	public static String getWeek(String sdate, String num) {

		Date dd = VeDate.strToDate(sdate);
		Calendar c = Calendar.getInstance();
		c.setTime(dd);
		if (num.equals("1"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		else if (num.equals("2"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
		else if (num.equals("3"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
		else if (num.equals("4"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
		else if (num.equals("5"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
		else if (num.equals("6"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
		else if (num.equals("0"))
			c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
		return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
	}

	public static String getWeek(String sdate) {
		Date date = VeDate.strToDate(sdate);
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		return new SimpleDateFormat("EEEE").format(c.getTime());
	}

	public static long getDays(String date1, String date2) {
		if (date1 == null || date1.equals(""))
			return 0;
		if (date2 == null || date2.equals(""))
			return 0;
		SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
		java.util.Date date = null;
		java.util.Date mydate = null;
		try {
			date = myFormatter.parse(date1);
			mydate = myFormatter.parse(date2);
		} catch (Exception e) {
		}
		long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
		return day;
	}

	public static String getNowMonth(String sdate) {
		sdate = sdate.substring(0, 8) + "01";
		Date date = VeDate.strToDate(sdate);
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int u = c.get(Calendar.DAY_OF_WEEK);
		String newday = VeDate.getNextDay(sdate, (1 - u) + "");
		return newday;
	}

	public static String getNo(int k) {

		return getUserDate("yyyyMMddhhmmss") + getRandom(k);
	}

	public static String getRandom(int i) {
		Random jjj = new Random();
		if (i == 0)
			return "";
		String jj = "";
		for (int k = 0; k < i; k++) {
			jj = jj + jjj.nextInt(9);
		}
		return jj;
	}

	public static boolean RightDate(String date) {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		;
		if (date == null)
			return false;
		if (date.length() > 10) {
			sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		} else {
			sdf = new SimpleDateFormat("yyyy-MM-dd");
		}
		try {
			sdf.parse(date);
		} catch (ParseException pe) {
			return false;
		}
		return true;
	}
}

4.4 MD5加密类

package com.util;

import java.security.MessageDigest;

/*
 * MD5 加密类
 * 这个类是网上获得的  通过这个类把
 *  一个字符串转化成一个16进制32位的字符串
 * */
public final class MD5 {

	public final static String md5(String s) {
		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; // 创建一个16进制数的数组
		try {
			byte[] strTemp = s.getBytes();// 把传入的字符串转化成数组
			MessageDigest mdTemp = MessageDigest.getInstance("MD5"); // 建立一个mdTemp
			// 类的对象
			// 对象名称叫做MD5实例
			mdTemp.update(strTemp);// 更新strTemp 数组
			byte[] md = mdTemp.digest(); // 通过digest() 方法重新定义一个数组
			int j = md.length; // md数组的长度
			char str[] = new char[j * 2]; // 定义一个字符数组 数组的长度是md数组长度的2倍
			int k = 0;
			for (int i = 0; i < j; i++) {
				byte byte0 = md[i]; // 给byte0变量赋值
				str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 通过hexDigits[]
				// 把字符串s转化成16进制32位的字符串
				str[k++] = hexDigits[byte0 & 0xf];
			}
			return new String(str); // 返回转换后的字符串
		} catch (Exception e) {
			return null;
		}
	}
}

 4.5 分页处理类

package com.util;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

public class PageHelper {

	public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
			HttpServletRequest request, String method) {
		StringBuffer buffer = new StringBuffer();
		String name2 = name.substring(0, 1).toUpperCase() + name.substring(1);
		String path = "";
		String action = "getAll" + name2 + ".action";
		if (method != null) {
			action = "query" + name2 + "ByCond.action";
		}

		List<Object> objList = new ArrayList<Object>();
		if (nameList != null && valueList != null) {
			for (int i = 0; i < nameList.size(); i++) {
				path += "&" + nameList.get(i) + "=" + valueList.get(i);
			}
		}
		int pageNumber = list.size();
		int maxPage = pageNumber;
		if (maxPage % pageSize == 0) {
			maxPage = maxPage / pageSize;
		} else {
			maxPage = maxPage / pageSize + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * pageSize;
		int over = (Integer.parseInt(number) + 1) * pageSize;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Object obj = list.get(i);
			objList.add(obj);
		}
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=0" + path + "\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
		}
		String html = buffer.toString();
		request.setAttribute("html", html);
		request.setAttribute(name + "List", objList);
	}

	public static void getUserPage(List<?> list, String name, String actionName, int pageSize, String number, HttpServletRequest request) {
		StringBuffer buffer = new StringBuffer();
		String path = "";
		String action = actionName + ".action";
		List<Object> objList = new ArrayList<Object>();
		int pageNumber = list.size();
		int maxPage = pageNumber;
		if (maxPage % pageSize == 0) {
			maxPage = maxPage / pageSize;
		} else {
			maxPage = maxPage / pageSize + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * pageSize;
		int over = (Integer.parseInt(number) + 1) * pageSize;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Object obj = list.get(i);
			objList.add(obj);
		}
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=0" + path + "\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
		}
		String html = buffer.toString();
		request.setAttribute("html", html);
		request.setAttribute(name + "List", objList);
	}

	public static void getIndexPage(List<?> list, String name, String actionName, String id, int pageSize, String number,
			HttpServletRequest request) {
		StringBuffer buffer = new StringBuffer();
		String path = "";
		String action = actionName + ".action";
		if (!"".equals(id) && id != null) {
			path = "&id=" + id + "";
		}
		List<Object> objList = new ArrayList<Object>();
		int pageNumber = list.size();
		int maxPage = pageNumber;
		if (maxPage % pageSize == 0) {
			maxPage = maxPage / pageSize;
		} else {
			maxPage = maxPage / pageSize + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * pageSize;
		int over = (Integer.parseInt(number) + 1) * pageSize;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Object obj = list.get(i);
			objList.add(obj);
		}
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"index/" + action + "?number=0" + path + "\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
		}
		String html = buffer.toString();
		request.setAttribute("html", html);
		request.setAttribute(name + "List", objList);
	}

}

5、项目内容包含

6、项目获取

6.1 方式一

私聊或者扫描下方名片获取项目文件。

6.2 方式二

点击此处直接获取项目文件。 

上一篇:C++系列-模版


下一篇:360° 镜头检测铝件内壁划痕与杂质:保障铝件内孔制造质量的精准方案