基于javaweb+mysql的jsp+servlet高校社团信息管理系统(java+jsp+html+javascript+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet高校社团信息管理系统(java+jsp+html+javascript+mysql)
项目介绍
管理员角色包含以下功能: 管理员登录,用户信息管理,社团创建审批,社团简介管理,学校器材管理,图片资讯查询,活动消息管理,新闻资讯管理,留言信息查询等功能。
社团管理员角色包含以下功能: 社团管理员登录,我的社团信息查询,社团成员查询,社团活动管理,社团新闻管理等功能。
用户角色包含以下功能: 查看所有新闻,用户注册,查看新闻,留言板留言,查看活动信息,创建社团,查看社团详细情况,申请加入社团,个人信息修改,创建社团审批详情,加入社团审批详情等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;
技术栈
HTML+CSS+JavaScript+jsp+mysql
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/login.jsp 登录
if (!StringUtil.isEmptyString(user.getUser_types())) {
sBuilder.append(" and user_type in (" + user.getUser_types() +") ");
}
sBuilder.append(" order by user_id asc) t");
if (user.getStart() != -1) {
sBuilder.append(" limit " + user.getStart() + "," + user.getLimit());
}
List<Object> list = BaseDao.executeQuery(User.class.getName(), sBuilder.toString(), null, conn);
if (list != null && list.size() > 0) {
users = new ArrayList<User>();
for (Object object : list) {
users.add((User)object);
}
}
return users;
}
public List<User> listAllUsers(User user, Connection conn){
List<User> users = null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM (");
sBuilder.append("SELECT * FROM user WHERE 1=1");
sBuilder.append(" order by user_id asc) t");
List<Object> list = BaseDao.executeQuery(User.class.getName(), sBuilder.toString(), null, conn);
if (list != null && list.size() > 0) {
users = new ArrayList<User>();
for (Object object : list) {
users.add((User)object);
}
}
return users;
}
public int listUsersCount(User user, Connection conn){
int sum = 0;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT count(*) FROM user WHERE 1=1");
if (user.getUser_id()!=0) {
sBuilder.append(" and user_id =" + user.getUser_id() +" ");
}
if (!StringUtil.isEmptyString(user.getUser_name())) {
sBuilder.append(" and user_name like '%" + user.getUser_name() +"%' ");
if (!StringUtil.isEmptyString(college.getReal_name())) {
sBuilder.append(" and u.real_name like '%" + college.getReal_name() + "%' ");
}
long count = (Long)BaseDao.executeQueryObject(sBuilder.toString(), null, conn);
sum = (int)count;
return sum;
}
}
public class BaseAction extends ActionSupport {
private static final long serialVersionUID = -3040899951717448806L;
private static final String ERROR_MSG = "msg";
private static final String ERROR_STACK = "errorStack";
// action执行结果(true|flase)
private boolean success = true;
// action执行结果(json插件返回客户端)
private Map<Object, Object> result = null;
// action执行结果原因(json插件返回客户端)
private Map<Object, Object> errorReason = new HashMap<Object, Object>();
@JSON(name = "data")
public Map<Object, Object> getResult() {
return result;
}
public void setResult(Map<Object, Object> result) {
this.result = result;
}
adminManager.delSblogs(paramsSblog);
} catch (Exception e) {
setErrorTip("删除异常", "Admin_listSblogs.action");
}
setSuccessTip("删除成功", "Admin_listSblogs.action");
return "infoTip";
}
private boolean validateAdmin(){
User admin = (User)Param.getSession("admin");
if (admin!=null) {
return true;
}else {
return false;
}
}
private void setErrorTip(String tip,String url){
Param.setAttribute("tipType", "error");
Param.setAttribute("tip", tip);
Param.setAttribute("url1", url);
Param.setAttribute("value1", "确 定");
}
private void setSuccessTip(String tip,String url){
Param.setAttribute("tipType", "success");
Param.setAttribute("tip", tip);
Param.setAttribute("url1", url);
Param.setAttribute("value1", "确 定");
}
public News getParamsNews() {
return paramsNews;
}
public void setParamsNews(News paramsNews) {
this.paramsNews = paramsNews;
* @param className 实体类的类名
* @return 实体类集合
*/
public static List<Object> getEntityListByInvoke(String className, ResultSet rs)
{
List<Object> list = new ArrayList<Object>();
try
{
while (rs.next())
{
Object o = Class.forName(className).newInstance();
ResultSetMetaData meta = rs.getMetaData();
for (int i = 1; i <= meta.getColumnCount(); i++)
{
String fieldName = meta.getColumnName(i); // 获取表的字段名称
Object value = rs.getObject(i); // 获取数据库表字段的值
invoke(o, fieldName, value); // 把值保存到o
}
list.add(o);
}
}
catch (SQLException e)
{
log.error("反射获取实体类集合异常:", e);
throw new RuntimeException("反射获取实体类集合异常:", e);
}
catch (InstantiationException e)
{
log.error("反射获取实体类集合异常:", e);
throw new RuntimeException("反射获取实体类集合异常:", e);
}
catch (IllegalAccessException e)
{
log.error("反射获取实体类集合异常:", e);
throw new RuntimeException("反射获取实体类集合异常:", e);
}
catch (ClassNotFoundException e)
{
log.error("反射获取实体类集合异常:", e);
throw new RuntimeException("反射获取实体类集合异常:", e);
}
return list;
}
/**
* 通过反射为实体类相应字段赋值
* @param o 实体类对象
* @param fieldName 要赋值的字段名称
* @param value 要给该字段赋的值
*/
public static void invoke(Object o, String fieldName, Object value)
sBuilder.append(" ,member_flag = " + member.getMember_flag() +" ");
}
sBuilder.append("where member_id = " + member.getMember_id() +" ");
Object[] params = null;
return BaseDao.executeUpdate(sBuilder.toString(), params, conn);
}
public Member getMember(Member member, Connection conn){
Member _member=null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM `member` WHERE 1=1");
if (member.getMember_id()!=0) {
sBuilder.append(" and member_id = " + member.getMember_id() +" ");
}
if (member.getCollege_id()!=0) {
sBuilder.append(" and college_id = " + member.getCollege_id() +" ");
}
if (member.getUser_id()!=0) {
sBuilder.append(" and user_id = " + member.getUser_id() +" ");
}
List<Object> list = BaseDao.executeQuery(Member.class.getName(), sBuilder.toString(), null, conn);
if (list != null && list.size() > 0) {
_member = (Member)list.get(0);
}
return _member;
}
public List<Member> listMembers(Member member, Connection conn){
List<Member> members = null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM (");
sBuilder.append("SELECT m.*,u.real_name,c.college_name FROM `member` m join user u on m.user_id=u.user_id ");
sBuilder.append(" join college c on m.college_id=c.college_id join user u2 on c.user_id=u2.user_id WHERE 1=1 ");
if (member.getMember_id()!=0) {
sBuilder.append(" and member_id = " + member.getMember_id() +" ");
}
if (member.getUser_id()!=0) {
sBuilder.append(" and m.user_id = " + member.getUser_id() +" ");
}
if (!StringUtil.isEmptyString(member.getReal_name())) {
sBuilder.append(" and u.real_name like '%" + member.getReal_name() + "%'");
}
if (!StringUtil.isEmptyString(member.getCollege_name())) {
sBuilder.append(" and c.college_name like '%" + member.getCollege_name() + "%'");
}
if (member.getMember_flag()!=0) {
sBuilder.append(" and member_flag =" + member.getMember_flag() + " ");
/**
* @Title: listActivitys
* @Description: 查询活动消息
* @param activity
* @return List<Activity>
*/
public List<Activity> listActivitys(Activity activity,int[] sum){
Connection conn = BaseDao.getConnection();
if (sum!=null) {
sum[0] = activityDao.listActivitysCount(activity, conn);
}
List<Activity> activitys = activityDao.listActivitys(activity,conn);
BaseDao.closeDB(null, null, conn);
return activitys;
}
/**
* @Title: getActivity
* @Description: 查询活动消息详情
* @param activity
* @return Activity
*/
public Activity getActivity(Activity activity){
Connection conn = BaseDao.getConnection();
Activity _activity = activityDao.getActivity(activity,conn);
BaseDao.closeDB(null, null, conn);
return _activity;
}
/**
* @Title: listSblogs
* @Description: 查询留言信息
* @param sblog
* @return List<Sblog>
*/
public List<Sblog> listSblogs(Sblog sblog,int[] sum){
Connection conn = BaseDao.getConnection();
if (sum!=null) {
sum[0] = sblogDao.listSblogsCount(sblog, conn);
public void setUser_id(int user_id){
this.user_id=user_id;
}
public int getUser_id(){
return user_id;
}
public void setActivity_title(String activity_title){
this.activity_title=activity_title;
}
public String getActivity_title(){
return activity_title;
}
public void setActivity_content(String activity_content){
this.activity_content=activity_content;
}
public String getActivity_contentShow(){
if (!StringUtil.isEmptyString(activity_content)) {
return Transcode.htmlDiscode(activity_content);
}
return activity_content;
}
public String getActivity_content(){
return activity_content;
}
public void setActivity_date(String activity_date){
this.activity_date=activity_date;
}
public String getActivity_date(){
return activity_date;
}
public void setActivity_address(String activity_address){
this.activity_address=activity_address;
}
public String getActivity_address(){
return activity_address;
}
public void setActivity_equip(String activity_equip){
this.activity_equip=activity_equip;
}
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
<div class="pageTitle">
<img src="images/right1.gif" align="middle" /> <span id="MainTitle" style="color:white">${admin.user_type==2?'社团活动':'活动消息' }>><s:if test="#attr.activity!=null && #attr.activity.activity_id!=0">编辑</s:if><s:else>发布</s:else>活动消息</span>
</div>
<form id="info" name="info" action="Admin_saveActivity.action" method="post">
<s:hidden id="paramsActivity.activity_id" name="paramsActivity.activity_id" value="%{#attr.activity.activity_id}" />
<table width="600" align="center" cellpadding="0" cellspacing="0" style="margin-top:10px;margin-bottom:10px;">
<tr>
<td height="24">
<Table border="0" cellspacing="0" cellpadding="0" align="center" width="100%">
<TR>
<TD height="24" class="edittitleleft"> </TD>
<TD class="edittitle"><s:if test="#attr.infos!=null">编辑</s:if><s:else>发布</s:else>活动消息</TD>
<TD class="edittitleright"> </TD>
</TR>
</TABLE>
</td>
</tr>
<tr>
<td height="1" bgcolor="#8f8f8f"></td>
</tr>
<tr>
<td >
<table width="100%" align="center" cellpadding="1" cellspacing="1" class="editbody">
<tr>
<td width="30%" align="right" style="padding-right:5px">活动名称:</td>
<td width="70%">
<s:textfield cssStyle="width:345px;" name="paramsActivity.activity_title" id="paramsActivity.activity_title" value="%{#attr.activity.activity_title}"/>
</td>
</tr>
<tr>
<td align="right" style="padding-right:5px">活动日期:</td>
<td>
<s:textfield name="paramsActivity.activity_date" id="paramsActivity.activity_date" value="%{#attr.activity.activity_date}" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"/>
</td>
</tr>
<tr>
sBuilder.append(" , college_money =" + college.getCollege_money() + " ");
}
if (!StringUtil.isEmptyString(college.getCollege_pic())) {
sBuilder.append(" , college_pic ='" + college.getCollege_pic() + "' ");
}
if (!StringUtil.isEmptyString(college.getCollege_note())) {
sBuilder.append(" , college_note ='" + college.getCollege_note() + "' ");
}
if (!StringUtil.isEmptyString(college.getCollege_plan())) {
sBuilder.append(" , college_plan ='" + college.getCollege_plan() + "' ");
}
if (college.getCollege_flag()!=0) {
sBuilder.append(" , college_flag =" + college.getCollege_flag() + " ");
}
sBuilder.append("where college_id = " + college.getCollege_id() +" ");
Object[] params = null;
return BaseDao.executeUpdate(sBuilder.toString(), params, conn);
}
public College getCollege(College college, Connection conn){
College _college=null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT c.*,u.real_name FROM college c join user u on c.user_id=u.user_id WHERE 1=1");
if (college.getCollege_id()!=0) {
sBuilder.append(" and college_id = " + college.getCollege_id() +" ");
}
if (!StringUtil.isEmptyString(college.getCollege_name())) {
sBuilder.append(" and college_name ='" + college.getCollege_name() + "' ");
}
List<Object> list = BaseDao.executeQuery(College.class.getName(), sBuilder.toString(), null, conn);
if (list != null && list.size() > 0) {
_college = (College)list.get(0);
}
return _college;
}
public List<College> listColleges(College college, Connection conn){
List<College> colleges = null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM (");
sBuilder.append("SELECT c.*,u.real_name FROM college c join user u on c.user_id=u.user_id WHERE 1=1");
if (college.getCollege_id()!=0) {
sBuilder.append(" and college_id = " + college.getCollege_id() +" ");
}
if (!StringUtil.isEmptyString(college.getCollege_name())) {
sBuilder.append(" and college_name like '%" + college.getCollege_name() + "%' ");
}
/**
* @Title: updateActivity
* @Description: 更新活动消息信息
* @param activity
* @return void
*/
public void updateActivity(Activity activity){
Connection conn = BaseDao.getConnection();
//活动消息内容编码后保存
if (!StringUtil.isEmptyString(activity.getActivity_content())) {
activity.setActivity_content(Transcode.htmlEncode(activity.getActivity_content()));
}
activityDao.updateActivity(activity, conn);
BaseDao.closeDB(null, null, conn);
}
/**
* @Title: delActivitys
* @Description: 删除活动消息信息
* @param activity
* @return void
*/
public void delActivitys(Activity activity){
Connection conn = BaseDao.getConnection();
activityDao.delActivitys(activity.getIds().split(","), conn);
BaseDao.closeDB(null, null, conn);
}
/**
* @Title: listNewss
* @Description: 新闻查询
* @param news
* @return List<News>
*/
public List<News> listNewss(News news,int[] sum){
Connection conn = BaseDao.getConnection();
if (sum!=null) {
sum[0] = newsDao.listNewssCount(news, conn);
}
List<News> newss = newsDao.listNewss(news,conn);
BaseDao.closeDB(null, null, conn);
return newss;
}
/**
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:if test="#attr.activity!=null && #attr.activity.activity_id!=0">编辑</s:if><s:else>发布</s:else>活动消息</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
$(document).ready(function(){
function trimStr(str)
{
if ((typeof(str) != "string") || !str)
{
return "";
}
return str.replace(/(^\s*)|(\s*$)/g, "");
}
var num=/^\d+(\.\d+)?$/;
$("#addBtn").bind('click',function(){
KE.sync('noticeContent');
if($("#paramsActivity\\.activity_title").val()==''){
alert("活动名称不能为空!");
return;
}
if($("#paramsActivity\\.activity_date").val()==''){
alert("活动日期不能为空!");
return;
}
if($("#paramsActivity\\.activity_address").val()==''){
alert("活动地点不能为空!");
return;
}
if($("#paramsActivity\\.activity_money").val()!=''){
if(!num.exec($("#paramsActivity\\.activity_money").val())){
alert('活动经费为数字');
return;
}
}else{
$("#paramsActivity\\.activity_money").val(0);
}
if($("#noticeContent").val()==''){
alert("活动内容不能为空!");
return;
}
$("#paramsActivity\\.activity_id").val(0);
$("#info").attr('action','Admin_addActivity.action').submit();
});
if (activity.getActivity_flag()!=0) {
sBuilder.append(" , activity_flag =" + activity.getActivity_flag() + " ");
}
sBuilder.append("where activity_id = " + activity.getActivity_id() +" ");
Object[] params = null;
return BaseDao.executeUpdate(sBuilder.toString(), params, conn);
}
public Activity getActivity(Activity activity, Connection conn){
Activity _activity=null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM activity WHERE 1=1");
if (activity.getActivity_id()!=0) {
sBuilder.append(" and activity_id = " + activity.getActivity_id() +" ");
}
List<Object> list = BaseDao.executeQuery(Activity.class.getName(), sBuilder.toString(), null, conn);
if (list != null && list.size() > 0) {
_activity = (Activity)list.get(0);
}
return _activity;
}
public List<Activity> listActivitys(Activity activity, Connection conn){
List<Activity> activitys = null;
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("SELECT * FROM (");
sBuilder.append("SELECT * FROM activity WHERE 1=1");
if (activity.getActivity_id()!=0) {
sBuilder.append(" and activity_id = " + activity.getActivity_id() +" ");
}
if (!StringUtil.isEmptyString(activity.getActivity_title())) {
sBuilder.append(" and activity_title like '%" + activity.getActivity_title() + "%' ");
}
if (!StringUtil.isEmptyString(activity.getActivity_content())) {
sBuilder.append(" and activity_content like '%" + activity.getActivity_content() + "%' ");
}
if (!StringUtil.isEmptyString(activity.getActivity_date())) {
sBuilder.append(" and activity_date ='" + activity.getActivity_date() + "' ");
}
if (activity.getActivity_flag()!=0) {
sBuilder.append(" and activity_flag =" + activity.getActivity_flag() + " ");
}
if (activity.getActivity_type()!=0) {
sBuilder.append(" and activity_type =" + activity.getActivity_type() + " ");
private static Logger log = Logger.getLogger(BaseDao.class);
private static ConnPoll connpoll=ConnPoll.getConnPollInstance();//数据库连接池对象
/**
* 构造方法
*/
public BaseDao() {
}
/**
* 得到数据库连接
*
* @throws ClassNotFoundException
* @throws SQLException
* @return 数据库连接
*/
public static Connection getConnection() {
return connpoll.getConn(); //获得数据库连接
}
/**
* 释放资源
*
* @param conn
* 数据库连接
* @param pstmt
* PreparedStatement对象
* @param rs
* 结果集
*/
public static void closeDB(ResultSet rs, PreparedStatement pstmt,
Connection conn) {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (conn != null) {
if (!conn.isClosed()) {
conn.close();
}
conn = null;
}
} catch (SQLException e) {
</td>
</tr>
<tr>
<td>
<table width="100%" align="center" cellpadding="0" cellspacing="0" class="editbody">
<tr class="editbody">
<td align="center" height="30">
<s:if test="#attr.activity!=null && #attr.activity.activity_id!=0">
<input type="button" id="editBtn" Class="btnstyle" value="编 辑"/>
</s:if>
<s:else>
<input type="button" id="addBtn" Class="btnstyle" value="添 加" />
</s:else>
<label style="color:red">${tip}</label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<script>
KE.show({
id : 'noticeContent',
items:['source', '|','plainpaste', '|', 'selectall', 'bold','italic'],
resizeMode:1
});
</script>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var tempClassName="";
function tr_mouseover(obj)
{
tempClassName=obj.className;
protected final HttpSession getHttpSession() {
HttpServletRequest request = ServletActionContext.getRequest();
return request.getSession();
}
/**
* 得到http response.
*
* @return http response
*/
protected final HttpServletResponse getHttpServletResponse() {
HttpServletResponse response = ServletActionContext.getResponse();
return response;
}
/**
* 设置分页属性.
*
* @param domain
* 输入DO对象
*/
protected void setPagination(BaseDomain domain) {
// 设置分页属性: start,limit,sort,order
domain.setStart((getPageNo() - 1) * getLimit());
domain.setLimit(getLimit());
domain.setSort(getSort());
domain.setOrder(getDir());
}
public int getPageCount() {
if (limit!=0) {
return (totalCount+limit-1)/limit;
}
return totalCount;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
if (!StringUtil.isEmptyString(college_note)) {
return Transcode.htmlDiscode(college_note);
}
return college_note;
}
public String getCollege_note(){
return college_note;
}
public void setCollege_plan(String college_plan){
this.college_plan=college_plan;
}
public String getCollege_plan(){
if (!StringUtil.isEmptyString(college_plan)) {
return Transcode.htmlDiscode(college_plan);
}
return college_plan;
}
public void setCollege_flag(int college_flag){
this.college_flag=college_flag;
}
public int getCollege_flag(){
return college_flag;
}
public void setIds(String ids) {
this.ids = ids;
}
public String getIds() {
return ids;
}
public void setRandom(String random) {
this.random = random;
}
public String getRandom() {
return random;
}
sBuilder.append(" and sblog_title like '%" + sblog.getSblog_title() +"%'");
}
if (sblog.getSblog_flag()!=0) {
sBuilder.append(" and sblog_flag = " + sblog.getSblog_flag() );
}
long count = (Long)BaseDao.executeQueryObject(sBuilder.toString(), null, conn);
sum = (int)count;
return sum;
}
}
public class EquipDao {
public int addEquip(Equip equip, Connection conn){
String sql = "INSERT INTO equip(equip_id,equip_name,equip_note) values(null,?,?)";
Object[] params = new Object[] {
equip.getEquip_name(),
equip.getEquip_note()
};
return BaseDao.executeUpdate(sql, params, conn );
}
public int delEquip(String equip_id, Connection conn){
String sql = "DELETE FROM equip WHERE equip_id=?";
Object[] params = new Object[] { new Integer(equip_id)};
return BaseDao.executeUpdate(sql, params, conn);
}
public int delEquips(String[] equip_ids, Connection conn){
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i <equip_ids.length; i++) {
sBuilder.append("?");
if (i !=equip_ids.length-1) {
sBuilder.append(",");
}
}