2022年java期中测试(部分问题尚未解决)

 

校园社团活动管理系统(20分)

1、项目需求:

校园社团作为高校课外活动的重要组成部分,发展十分迅速,也受到越来越多学生的欢迎,社团规模、数量等都在日益增长,社团活动也更为多样和丰富。然而,大多数高校还没有一个完整成熟的社团管理系统,仅仅是靠人力来管理,导致效率低下,而学生也只能通过线下或者公众号的方式了解社团,另外,社团活动的通知方式也很杂乱,并没有一个信息聚合、消息发布的平台。

因此,高校有必要建立一个校园社团管理系统,使得社团管理工作规范化、系统化、程序化、科学化,提高管理工作的效率。

2.系统要求与功能设计

2.1 页面功能要求

(1)能够在Tomcat服务器中正确部署,并通过浏览器查看;(1分)

(2)网站页面整体风格统一;

 

图1 活动普查系统功能结构图

(3)主页面:要求显示发布活动信息、修改活动信息、删除活动信息、查询活动信息,活动信息浏览五个子菜单。(1分)

(4)发布活动信息页面:(6分)

①完成添加活动信息发布,基本信息和填报限制如下表所示

活动主题

字符串(不超过20个汉字)

活动目的

字符串(不超过50个汉字)

活动类型

社团竞赛、野外采风、校内集会、社团纳新(单选框)

活动时间

文本框

活动地点

文本框

活动对象

社团成员、全体学生(复选框实现)

活动内容

(文本框,不超过500个汉字)

活动日程安排

(文本框,不超过500个汉字)

 

②点击“提交”按钮,保存成功则跳转到活动基本信息浏览界面,新录入的信息置顶显示。失败则提示错误信息,返回当前页面

评分标准:

①  完成活动信息发布页面(未完成0分,完成1分)

②  保存活动信息入库(未完成0分,完成1分)

③  社团竞赛、野外采风、校内集会、社团纳新实现单选框录入1分。(未完成0分,全部完成1分)

④  实现活动对象复选框录入1分。(未完成0分,完成1分)

⑤  实现活动主题、活动目的、活动内容、活动日程安排的字数判断,实现三个以上得1分(未完成0分,完成1分)

⑥提交后页面跳转功能;(未完成0分,完成1分)

(5)修改活动信息页面:(3分)

输入活动主题,显示其余信息,可对活动目的、活动类型、活动时间、活动地点、活动对象、活动内容、活动日程安排进行修改。(活动目的、活动类型、活动时间、活动地点、活动对象、活动内容、活动日程安排必须符合录入要求);如果该活动主题数据库不存在,则提示“该活动不存在”。(3分)

评分标准:

①  完成修改活动信息页面(未完成0分,完成1分)

②   实现数据库中信息更新(未完成0分,完成1分)

③输入活动主题,显示其余信息,若该信息不存在,提示错误信息;(未完成0分,完成1分)

(6)删除活动信息页面:录入活动主题,显示详细信息后,点击“删除”按钮,弹出提示框,提示“是否确认删除该活动信息”,确认后删除该信息。(1分)

评分标准:

①  输入活动主题可显示其余信息。(未完成0分,完成0.5分)

②对应删除数据库中信息(未完成0分,完成0.5分)

(7)浏览活动信息页面:(2分)

以列表形式显示活动基本信息,结果列表中显示活动主题、活动时间,活动类型、活动对象基本信息,点击主题,可以跳转到活动详细信息,显示全部活动信息。

①  实现以列表形式显示活动基本信息,结果列表中显示活动主题、活动时间,活动类型、活动对象基本信息(未完成0分,完成1分)

②实现跳转活动详细信息页面,显示全部活动信息。(未完成0分,完成1分)

(8)查询活动信息页面:(3分)

要求根据活动主题、活动时间、活动类型、活动地点四种条件实现模糊查询,输出结果以列表形式显示,显示显示活动主题、活动时间,活动类型、活动对象基本信息,点击列表中的活动主题,跳转到活动详细信息页面。

评分标准:

①缺少一种查询条件扣除1分。(未完成0分,完成3分)

2.2 功能要求

(1)设计出合理的数据库和数据表,要求使用mysql、sqlserver、oracle三种数据库中一种(1分)

(2)使用Serverlet实现页面交互(1分)。

(3)使用Java Bean封装数据库连接操作(1分。)

 

参考:JavaWeb项目-人口普查系统 - 学习中_1 - 博客园 (cnblogs.com)

.java文件(1个)(2个没用的)

  1 //data.huodongxinxi
  2 
  3 package data;
  4 import java.sql.*;
  5 import java.util.regex.Pattern;
  6 import javabean.bean;
  7 public class huodongxinxi {
  8     private String hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai;
  9 
 10     public String getHdzhuti() {
 11         return hdzhuti;
 12     }
 13 
 14     public void setHdzhuti(String hdzhuti) {
 15         this.hdzhuti = hdzhuti;
 16     }
 17 
 18     public String getHdmudi() {
 19         return hdmudi;
 20     }
 21 
 22     public void setHdmudi(String hdmudi) {
 23         this.hdmudi = hdmudi;
 24     }
 25 
 26     public String getHdleixing() {
 27         return hdleixing;
 28     }
 29 
 30     public void setHdleixing(String hdleixing) {
 31         this.hdleixing = hdleixing;
 32     }
 33 
 34     public String getHdshijian() {
 35         return hdshijian;
 36     }
 37 
 38     public void setHdshijian(String hdshijian) {
 39         this.hdshijian = hdshijian;
 40     }
 41 
 42     public String getHddidian() {
 43         return hddidian;
 44     }
 45 
 46     public void setHddidian(String hddidian) {
 47         this.hddidian = hddidian;
 48     }
 49 
 50     public String getHdduixiang() {
 51         return hdduixiang;
 52     }
 53 
 54     public void setHdduixiang(String hdduixiang) {
 55         this.hdduixiang = hdduixiang;
 56     }
 57 
 58     public String getHdneirong() {
 59         return hdneirong;
 60     }
 61 
 62     public void setHdneirong(String hdneirong) {
 63         this.hdneirong = hdneirong;
 64     }
 65 
 66     public String getHdrichenganpai() {
 67         return hdrichenganpai;
 68     }
 69 
 70     public void setHdrichenganpai(String hdrichenganpai) {
 71         this.hdrichenganpai = hdrichenganpai;
 72     }
 73 
 74     public Connection getConnection(){
 75         try {
 76             Class.forName("com.mysql.cj.jdbc.Driver");
 77             //System.out.println("加载驱动成功");
 78         }catch(Exception e)
 79         {
 80             e.printStackTrace();
 81         }
 82         String user="root";
 83         String password="1234";
 84         String url = "jdbc:mysql://localhost:3306/huodong?useSSL=false&serverTimezone=GMT&characterEncoding=utf-8&autoReconnect=true";
 85         //
 86         Connection con=null;
 87         try{
 88             con=DriverManager.getConnection(url,user,password);
 89             //System.out.println("数据库连接成功");
 90         }catch(SQLException e)
 91         {
 92             e.printStackTrace();
 93         }
 94         return con;
 95     }
 96 
 97 
 98     //关闭方法
 99     public  void close (Connection con)
100     {
101         try{
102             if(con!=null)
103             {
104                 con.close();
105             }
106         }catch(SQLException e)
107         {
108             e.printStackTrace();
109         }
110     }
111     public  void close (PreparedStatement preparedStatement)
112     {
113         try{
114             if(preparedStatement!=null)
115             {
116                 preparedStatement.close();
117             }
118         }catch(SQLException e)
119         {
120             e.printStackTrace();
121         }
122     }
123     public  void close(ResultSet resultSet)
124     {
125         try{
126             if(resultSet!=null)
127             {
128                 resultSet.close();
129             }
130         }catch(SQLException e)
131         {
132             e.printStackTrace();
133         }
134     }
135 
136 
137     //******************************************************************
138     //
139     public void adddata(String hdzhuti,String hdmudi,String hdleixing,String hdshijian,
140                         String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)
141     {
142         Connection connection = getConnection();
143         PreparedStatement preparedStatement=null;
144         try {
145             //hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai
146             String sql = "insert into t0 (活动主题,活动目的,活动类型,活动时间,活动地点,活动对象,活动内容,活动日程安排) values (?,?,?,?,?,?,?,?)";
147             preparedStatement=connection.prepareStatement(sql);
148             preparedStatement.setString(1,hdzhuti);
149             preparedStatement.setString(2,hdmudi);
150             preparedStatement.setString(3,hdleixing);
151             preparedStatement.setString(4,hdshijian);
152             preparedStatement.setString(5,hddidian);
153             preparedStatement.setString(6,hdduixiang);
154             preparedStatement.setString(7,hdneirong);
155             preparedStatement.setString(8,hdrichenganpai);
156             preparedStatement.executeUpdate();
157             //System.out.println("添加成功");
158 
159         } catch (SQLException  e) {
160             e.printStackTrace();
161         }finally{
162             close(preparedStatement);
163             close(connection);
164         }
165     }
166     //
167     public void deletedata(String hdzhuti)
168     {
169         Connection connection = getConnection();
170         PreparedStatement preparedStatement=null;
171         try {
172             String sql = "delete from t0 where 活动主题 = ?";
173             preparedStatement=connection.prepareStatement(sql);
174             preparedStatement.setString(1,hdzhuti);
175             preparedStatement.executeUpdate();
176             //System.out.println("删除成功");
177 
178         } catch (SQLException  e) {
179             e.printStackTrace();
180         }finally{
181             close(preparedStatement);
182             close(connection);
183         }
184     }
185     //
186     public void revisedata(String hdzhuti0,String hdmudi,String hdleixing,String hdshijian,
187                            String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)
188     {
189         Connection connection = getConnection();
190         PreparedStatement preparedStatement=null;
191         try {
192             //身份证号码、性别、民族、受教育程度
193             String sql = "update t0 set 活动目的=?, 活动类型=?, 活动时间=?, 活动地点=?, 活动对象=?, 活动内容=?, 活动日程安排=? where 活动主题=?";
194             preparedStatement=connection.prepareStatement(sql);
195             preparedStatement.setString(1,hdmudi);
196             preparedStatement.setString(2,hdleixing);
197             preparedStatement.setString(3,hdshijian);
198             preparedStatement.setString(4,hddidian);
199             preparedStatement.setString(5,hdduixiang);
200             preparedStatement.setString(6,hdneirong);
201             preparedStatement.setString(7,hdrichenganpai);
202             preparedStatement.setString(8,hdzhuti0);
203             preparedStatement.executeUpdate();
204 
205         } catch (SQLException  e) {
206             e.printStackTrace();
207         }finally{
208             close(preparedStatement);
209             close(connection);
210         }
211     }
212     //判断方法****************************************************************
213     //判空
214     public boolean isEmpty(String hdzhuti,String hdmudi,String hdleixing,String hdshijian,
215                            String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)
216     {
217         if(hdzhuti==null||hdmudi==null||hdleixing==""||hdshijian==""||hddidian==""||hdduixiang==""||hdneirong==null||hdrichenganpai=="")
218             return true;
219         else
220             return false;
221     }
222 
223     //判长度20
224     public boolean isLength_20(String hdzhuti) {
225         if (hdzhuti.length() <= 20)
226             return true;
227         else return false;
228     }
229     //判长度50
230     public boolean isLength_50(String hdmudi) {
231         if (hdmudi.length() <= 50)
232             return true;
233         else return false;
234     }
235     //判长度500
236     public boolean isLength_500(String hd) {
237         if (hd.length() <= 500)
238             return true;
239         else return false;
240     }
241     
242     //判重/判存在
243     public boolean isSame(String s)
244     {
245         Connection connection = getConnection();
246         PreparedStatement preparedStatement=null;
247         ResultSet rs=null;
248         try {
249             String sql = "select * from t0";
250             preparedStatement=connection.prepareStatement(sql);
251             rs=preparedStatement.executeQuery();
252             while(rs.next()){
253                 if( s.equals(rs.getObject(1)))
254                     return true;
255             }
256             //preparedStatement.executeUpdate();
257 
258         } catch (SQLException  e) {
259             e.printStackTrace();
260         }finally{
261             close(rs);
262             close(preparedStatement);
263             close(connection);
264         }
265         return false;
266     }
267 
268 
269     //*****************************************************************
270     public static void main(String[] args)
271     {
272         //Data a=new Data();
273     }
274 
275 }
View Code
//javabean.bean
package javabean;

import java.sql.*;
import java.util.regex.Pattern;
import javabean.bean;
public class bean {
    public Connection getConnection(){
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            //System.out.println("加载驱动成功");
        }catch(Exception e)
        {
            e.printStackTrace();
        }
        String user="root";
        String password="1234";
        String url = "jdbc:mysql://localhost:3306/huodong?useSSL=false&serverTimezone=GMT&characterEncoding=utf-8&autoReconnect=true";
        //
        Connection con=null;
        try{
            con= DriverManager.getConnection(url,user,password);
            //System.out.println("数据库连接成功");
        }catch(SQLException e)
        {
            e.printStackTrace();
        }
        return con;
    }

    public  void close (Connection con)
    {
        try{
            if(con!=null)
            {
                con.close();
            }
        }catch(SQLException e)
        {
            e.printStackTrace();
        }
    }
    public  void close (PreparedStatement preparedStatement)
    {
        try{
            if(preparedStatement!=null)
            {
                preparedStatement.close();
            }
        }catch(SQLException e)
        {
            e.printStackTrace();
        }
    }
    public  void close(ResultSet resultSet)
    {
        try{
            if(resultSet!=null)
            {
                resultSet.close();
            }
        }catch(SQLException e)
        {
            e.printStackTrace();
        }
    }
}
View Code
//make.makee
package make;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.*;
import java.util.regex.Pattern;
import javabean.bean;

public class makee {
    bean bean = new bean();
    //
    public void adddata(String hdzhuti,String hdmudi,String hdleixing,String hdshijian,
                        String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)
    {
        Connection connection = bean.getConnection();
        PreparedStatement preparedStatement=null;
        try {
            //hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai
            String sql = "insert into t0 (活动主题,活动目的,活动类型,活动时间,活动地点,活动对象,活动内容,活动日程安排) values (?,?,?,?,?,?,?,?)";
            preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1,hdzhuti);
            preparedStatement.setString(2,hdmudi);
            preparedStatement.setString(3,hdleixing);
            preparedStatement.setString(4,hdshijian);
            preparedStatement.setString(5,hddidian);
            preparedStatement.setString(6,hdduixiang);
            preparedStatement.setString(7,hdneirong);
            preparedStatement.setString(8,hdrichenganpai);
            preparedStatement.executeUpdate();
            //System.out.println("添加成功");

        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            bean.close(preparedStatement);
            bean.close(connection);
        }
    }
    //
    public void deletedata(String hdzhuti)
    {
        Connection connection = bean.getConnection();
        PreparedStatement preparedStatement=null;
        try {
            String sql = "delete from t0 where 活动主题 = ?";
            preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1,hdzhuti);
            preparedStatement.executeUpdate();
            //System.out.println("删除成功");

        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            bean.close(preparedStatement);
            bean.close(connection);
        }
    }
    //
    public void revisedata(String hdzhuti0,String hdmudi,String hdleixing,String hdshijian,
                           String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)
    {
        Connection connection = bean.getConnection();
        PreparedStatement preparedStatement=null;
        try {
            //身份证号码、性别、民族、受教育程度
            String sql = "update t0 set 活动目的=?, 活动类型=?, 活动时间=?, 活动地点=?, 活动对象=?, 活动内容=?, 活动日程安排=? where 活动主题=?";
            preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1,hdmudi);
            preparedStatement.setString(2,hdleixing);
            preparedStatement.setString(3,hdshijian);
            preparedStatement.setString(4,hddidian);
            preparedStatement.setString(5,hdduixiang);
            preparedStatement.setString(6,hdneirong);
            preparedStatement.setString(7,hdrichenganpai);
            preparedStatement.setString(8,hdzhuti0);
            preparedStatement.executeUpdate();

        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            bean.close(preparedStatement);
            bean.close(connection);
        }
    }
}
View Code

.jsp文件(14个)

 index.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>主菜单</title>
</head>

<form action="addInput.jsp" method="get">
  <p style="text-align:center;color:black;font-family:宋体; font-size:20px">校园社团活动管理系统

    <br> 选择功能: <input type="button" value="发布活动信息" onclick="location.href='tianjia.jsp'" />
    <input type="button" value="修改活动信息" onclick="location.href='xiugai.jsp'" />
    <input type="button" value="删除活动信息" onclick="location.href='shanchu.jsp'" />
    <input type="button" value="查询活动信息" onclick="location.href='chaxun.jsp'" />
    <input type="button" value="活动信息浏览" onclick="location.href='show.jsp'" />
    <br>
  </p>

</form>
</body>

</html>

tianjia.jsp

<%@page import="data.huodongxinxi"%>
<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>发布</title>
</head>
<body>
<form action="tianjiapd.jsp" method="get">
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        发布活动信息页面
        <br>
        <br>

        <br> 活动主题
        <input type="text" name="hdzhuti" size="4"/>
        <br>

        <br> 活动目的
        <input type="text" name="hdmudi" size="4"/>
        <br>

        <br>活动类型
        <input type="radio" name="hdleixing" value="社团竞赛" />社团竞赛
        <input type="radio" name="hdleixing" value="野外采风" />野外采风
        <input type="radio" name="hdleixing" value="校内集会" />校内集会
        <input type="radio" name="hdleixing" value="社团纳新" />社团纳新

        <br> 活动时间
        <input type="text" name="hdshijian" size="4"/>
        <br>

        <br> 活动地点
        <input type="text" name="hddidian" size="4"/>
        <br>

        <br> 活动对象
        <input type="checkbox" name="hdduixiang1" value="社团成员"/>社团成员
        <input type="checkbox" name="hdduixiang2" value="全体学生" checked/>全体学生
        <br />

        <br> 活动内容
        <input type="text" name="hdneirong" size="4"/>
        <br>

        <br> 活动日程安排
        <input type="text" name="hdrichenganpai" size="4"/>
        <br>

        <br><input type="submit" value="提交" />
        <input type="reset" value="重置" />  <br>
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
    </p>
</form>
</body>
</html>

tianjiapd.jsp

<%@ page import="java.util.Arrays" %>
<%@ page import="java.io.IOException" %>
<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    //hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai
    String hdzhuti=(String)request.getParameter("hdzhuti");
    String hdmudi=(String)request.getParameter("hdmudi");
    String hdleixing=(String)request.getParameter("hdleixing");
    String hdshijian=(String)request.getParameter("hdshijian");
    String hddidian=(String)request.getParameter("hddidian");


    String hdduixiang = "";
    if(request.getParameter("hdduixiang1")!=null)
        hdduixiang+=request.getParameter("hdduixiang1");
    if(request.getParameter("hdduixiang2")!=null)
        hdduixiang+=request.getParameter("hdduixiang2");

//    String[] hddx = request.getParameter("hdduixiang");
//
//    String hdduixiang = Arrays.toString(hddx);
//    hdduixiang = hdduixiang.substring(1, hdduixiang.length()-1);

    String hdneirong=(String)request.getParameter("hdneirong");
    String hdrichenganpai=(String)request.getParameter("hdrichenganpai");



    if(util.isEmpty(hdzhuti,hdmudi,hdleixing,hdshijian,hddidian,hdduixiang,hdneirong,hdrichenganpai)){
        out.print("<script language='javaScript'> alert('输入为空');window.history.back(-1);</script>");
    }
    else if(!util.isLength_20(hdzhuti))
    {
        out.print("<script language='javaScript'> alert('活动主题字数应少于20');window.history.back(-1);</script>");
    }
    else if(!util.isLength_50(hdmudi))
    {
        out.print("<script language='javaScript'> alert('活动目的字数应少于50');window.history.back(-1);</script>");
    }
    else if(!util.isLength_500(hdneirong))
    {
        out.print("<script language='javaScript'> alert('活动内容字数应少于500');window.history.back(-1);</script>");
    }
    else if(!util.isLength_500(hdrichenganpai))
    {
        out.print("<script language='javaScript'> alert('活动日程安排字数应少于500');window.history.back(-1);</script>");
    }
    else if(util.isSame(hdzhuti))
    {
        out.print("<script language='javaScript'> alert('该主题已经发布过了');window.history.back(-1);</script>");
    }


    else{
        util.adddata(hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai);
        out.print("<script language='javaScript'> alert('添加成功');</script>");
        response.setHeader("refresh", "0;url=show.jsp");
    }



%>
</body>
</html>

shanchu.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>删除</title>
</head>
<body>
<form action="shanchupd.jsp" method="get">
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        删除活动信息
        <br> 要删除信息的活动主题: <input type="text" name="hdzhuti" /> <br>
        <br><input type="submit" value="确定" />
        <input type="reset" value="重置" />  <br>
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
    </p>
</form>
</body>
</html>

shanchupd.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" import="java.sql.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>

<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    String hdzhuti=(String)request.getParameter("hdzhuti");
    if(hdzhuti==""){
        out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
    }
    else if(!util.isSame(hdzhuti))
    {
        out.print("<script language='javaScript'> alert('该活动主题不存在'); window.history.back(-1); </script>");
    }
    else{
%>
<table border="1"style="text-align:center;">
    <tr>

        <td align="center" width=6%>活动主题</td>
        <td align="center" width=8%>活动目的</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
        <td align="center" width=18%>活动对象</td>
        <td align="center" width=3%>活动内容</td>
        <td align="center" width=10>活动日程安排</td>

    </tr>
    <%
        Connection connection = util.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet rs=null;
        try {
            String sql = "select * from t0";
            preparedStatement=connection.prepareStatement(sql);
            rs=preparedStatement.executeQuery();
            while(rs.next()){
                if(hdzhuti.equals(rs.getObject(1)))
                {
    %>
    <tr>
        <td align="center"><%=rs.getObject(1) %></td>
        <td align="center"><%=rs.getObject(2) %></td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
        <td align="center"><%=rs.getObject(6) %></td>
        <td align="center"><%=rs.getObject(7) %></td>
        <td align="center"><%=rs.getObject(8) %></td>
        <td align="center"><a style="color:blue" href='shanchupd2.jsp?hdzhuti=<%=rs.getObject(1) %>' onclick="javascript:return del()">删除</a> </td>
    </tr>

    <%
                }
            }
        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            util.close(rs);
            util.close(preparedStatement);
            util.close(connection);
        }
    %>
</table>
<%
    }
%>

<script>
    function del(){
        var r = confirm("确定要删除吗?")
        if (r == true) {
            return true;
        } else {
            return false;
        }
    }
</script>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

shanchupd2.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<input type="button" onclick="openResult()" value="删除"/>
<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    String hdzhuti=(String)request.getParameter("hdzhuti");
    util.deletedata(hdzhuti);
    out.print("<script language='javaScript'> alert('删除成功');</script>");
    response.setHeader("refresh", "0;url=shanchu.jsp");
%>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

xiugai.jsp

<%@page import="data.huodongxinxi"%>
<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改</title>
</head>
<body>
<form action="xiugaipd.jsp" method="get">
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        <br> 输入要修改的活动主题 <input type="text" name="hdzhuti" /><br>

        <br><input type="submit" value="提交" />
        <input type="reset" value="重置" />  <br>
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
    </p>
</form>
</body>
</html>

xiugaipd.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" import="java.sql.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改</title>
</head>
<body>

<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    String hdzhuti=(String)request.getParameter("hdzhuti");
    if(hdzhuti==""){
        out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
    }
    else if(!util.isSame(hdzhuti))
    {
        out.print("<script language='javaScript'> alert('该活动主题不存在'); window.history.back(-1); </script>");
    }
    else{
%>
<table border="1"style="text-align:center;">
    <tr>
        <td align="center" width=6%>活动主题</td>
        <td align="center" width=8%>活动目的</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
        <td align="center" width=18%>活动对象</td>
        <td align="center" width=3%>活动内容</td>
        <td align="center" width=10>活动日程安排</td>

    </tr>
    <%
        Connection connection = util.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet rs=null;
        try {
            String sql = "select * from t0";
            preparedStatement=connection.prepareStatement(sql);
            rs=preparedStatement.executeQuery();
            while(rs.next()){
                if(hdzhuti.equals(rs.getObject(1)))
                {
    %>
    <tr>
        <td align="center"><%=rs.getObject(1) %></td>
        <td align="center"><%=rs.getObject(2) %></td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
        <td align="center"><%=rs.getObject(6) %></td>
        <td align="center"><%=rs.getObject(7) %></td>
        <td align="center"><%=rs.getObject(8) %></td>
        <td align="center"><a style="color:blue" href='xiugaipd2.jsp?hdzhuti0=<%=rs.getObject(1) %>'>修改</a> </td>
    </tr>
    <%
                }
            }
        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            util.close(rs);
            util.close(preparedStatement);
            util.close(connection);
        }
    %>
</table>
<%
    }
%>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

xiugaipd2.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" import="java.sql.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    String hdzhuti0=(String)request.getParameter("hdzhuti0");
    session.setAttribute("hdzhuti0",hdzhuti0);
%>
<table border="1"style="text-align:center;">
    <tr>
        <td align="center" width=6%>活动主题</td>
        <td align="center" width=8%>活动目的</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
        <td align="center" width=18%>活动对象</td>
        <td align="center" width=3%>活动内容</td>
        <td align="center" width=10>活动日程安排</td>
    </tr>
    <%
        Connection connection = util.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet rs=null;
        try {
            String sql = "select * from t0";
            preparedStatement=connection.prepareStatement(sql);
            rs=preparedStatement.executeQuery();
            while(rs.next()){
                if(hdzhuti0.equals(rs.getObject(1)))
                {
    %>
    <tr>
        <td align="center"><%=rs.getObject(1) %></td>
        <td align="center"><%=rs.getObject(2) %></td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
        <td align="center"><%=rs.getObject(6) %></td>
        <td align="center"><%=rs.getObject(7) %></td>
        <td align="center"><%=rs.getObject(8) %></td>
    </tr>
    <%
                }
            }
        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            util.close(rs);
            util.close(preparedStatement);
            util.close(connection);
        }
    %>
</table>

<form action="xiugaipd3.jsp" method="get">
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        <br>
        <br>
        修改活动信息

        <br> 活动目的
        <input type="text" name="hdmudi" size="4"/>
        <br>

        <br>活动类型
        <input type="radio" name="hdleixing" value="社团竞赛" />社团竞赛
        <input type="radio" name="hdleixing" value="野外采风" />野外采风
        <input type="radio" name="hdleixing" value="校内集会" />校内集会
        <input type="radio" name="hdleixing" value="社团纳新" />社团纳新

        <br> 活动时间
        <input type="text" name="hdshijian" size="4"/>
        <br>

        <br> 活动地点
        <input type="text" name="hddidian" size="4"/>
        <br>

        <br> 活动对象
        <input type="checkbox" name="hdduixiang1" value="社团成员"/>社团成员
        <input type="checkbox" name="hdduixiang2" value="全体学生" checked/>全体学生
        <br />

        <br> 活动内容
        <input type="text" name="hdneirong" size="4"/>
        <br>

        <br> 活动日程安排
        <input type="text" name="hdrichenganpai" size="4"/>
        <br>

        <br><input type="submit" value="提交" />
        <input type="reset" value="重置" />  <br>
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
    </p>
</form>
</body>
</html>

xiugaipd3.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<%
    //hdzhuti, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai
    String hdzhuti0=(String)session.getAttribute("hdzhuti0");
//    String hdzhuti00=(String)request.getParameter("hdzhuti00");
    String hdmudi=(String)request.getParameter("hdmudi");
    String hdleixing=(String)request.getParameter("hdleixing");
    String hdshijian=(String)request.getParameter("hdshijian");
    String hddidian=(String)request.getParameter("hddidian");

    String hdduixiang = "";
    if(request.getParameter("hdduixiang1")!=null)
        hdduixiang+=request.getParameter("hdduixiang1");
    if(request.getParameter("hdduixiang2")!=null)
        hdduixiang+=request.getParameter("hdduixiang2");

    String hdneirong=(String)request.getParameter("hdneirong");
    String hdrichenganpai=(String)request.getParameter("hdrichenganpai");



    if(util.isEmpty(hdzhuti0,hdmudi,hdleixing,hdshijian,hddidian,hdduixiang,hdneirong,hdrichenganpai)){
        out.print("<script language='javaScript'> alert('输入为空');window.history.back(-1);</script>");
    }
    else if(!util.isLength_20(hdzhuti0))
    {
        out.print("<script language='javaScript'> alert('活动主题字数应少于20');window.history.back(-1);</script>");
    }
    else if(!util.isLength_50(hdmudi))
    {
        out.print("<script language='javaScript'> alert('活动目的字数应少于50');window.history.back(-1);</script>");
    }
    else if(!util.isLength_500(hdneirong))
    {
        out.print("<script language='javaScript'> alert('活动内容字数应少于500');window.history.back(-1);</script>");
    }
    else if(!util.isLength_500(hdrichenganpai))
    {
        out.print("<script language='javaScript'> alert('活动日程安排字数应少于500');window.history.back(-1);</script>");
    }
//    else if(util.isSame(hdzhuti0))
//    {
//        out.print("<script language='javaScript'> alert('该主题已经发布过了');window.history.back(-1);</script>");
//    }
    else
    {
        util.revisedata(hdzhuti0, hdmudi, hdleixing, hdshijian, hddidian, hdduixiang, hdneirong, hdrichenganpai);
        out.print("<script language='javaScript'> alert('修改成功');</script>");
        response.setHeader("refresh", "0;url=show.jsp");
        //revisedata(String hdzhuti0,String hdmudi,String hdleixing,String hdshijian,
        // String hddidian,String hdduixiang,String hdneirong,String hdrichenganpai)

    }

%>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

show.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" import="java.sql.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>活动信息浏览</title>
</head>
<body>


<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
<table border="1"style="text-align:center;">
    <tr>
        <td align="center" width=6%>活动主题</td>
        <td align="center" width=8%>活动目的</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
        <td align="center" width=18%>活动对象</td>
        <td align="center" width=3%>活动内容</td>
        <td align="center" width=10>活动日程安排</td>
    </tr>
    <%
        Connection connection = util.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet rs=null;
        try {
            String sql = "select * from t0";
            preparedStatement=connection.prepareStatement(sql);
            rs=preparedStatement.executeQuery();
            while(rs.next()){
    %>
    <tr>
        <td align="center"><%=rs.getObject(1) %></td>
        <td align="center"><%=rs.getObject(2) %></td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
        <td align="center"><%=rs.getObject(6) %></td>
        <td align="center"><%=rs.getObject(7) %></td>
        <td align="center"><%=rs.getObject(8) %></td>
    </tr>
    <%
            }
        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            util.close(rs);
            util.close(preparedStatement);
            util.close(connection);
        }
    %>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

chaxun.jsp

<%@ page language="java" import="javabean.bean" import="make.makee" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>查询</title>
</head>
<body>
<form action="chaxunpd.jsp" method="get">
    <p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
        输入要查询信息的活动主题/活动时间/活动类型/活动地点(支持模糊查询):
        <br> <input type="text" name="data" /> <br>
        <br><input type="submit" value="提交" />
        <input type="reset" value="重置" />  <br>
        <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
    </p>
</form>
</body>
</html>

chaxunall.jsp

<%@ page language="java" import="java.sql.*" import="make.makee" import="javabean.bean" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>详细信息</title>
</head>
<body>


<jsp:useBean id="util" class="data.huodongxinxi" scope="page" />

<%
    String hdzhuti0 = (String)request.getParameter("hdzhuti0");
    Connection connection = util.getConnection();
    PreparedStatement preparedStatement=null;
    ResultSet rs=null;
    try {
        String sql = "select * from t0";
        preparedStatement=connection.prepareStatement(sql);
        rs=preparedStatement.executeQuery();
        while(rs.next()){
            if(hdzhuti0.equals(rs.getObject(1)))
            {
%>
<table border="1"style="text-align:center;">
    <tr>
        <td align="center" width=6%>活动主题</td>
        <td align="center" width=8%>活动目的</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
        <td align="center" width=18%>活动对象</td>
        <td align="center" width=3%>活动内容</td>
        <td align="center" width=10>活动日程安排</td>
    </tr>
    <tr>
        <td align="center"><%=rs.getObject(1) %></td>
        <td align="center"><%=rs.getObject(2) %></td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
        <td align="center"><%=rs.getObject(6) %></td>
        <td align="center"><%=rs.getObject(7) %></td>
        <td align="center"><%=rs.getObject(8) %></td>
    </tr>
    <%
                }
            }
        } catch (SQLException  e) {
            e.printStackTrace();
        }finally{
            util.close(rs);
            util.close(preparedStatement);
            util.close(connection);
        }
    %>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <input type="button" name="back" onclick="javascript:window.history.back(-1);" value=返回上一页>
    <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

chaxunpd.jsp

<%@ page language="java" import="java.sql.*" import="make.makee" import="javabean.bean" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>查询</title>
</head>
<body style="text-align:center">
查询结果
<p>
    <jsp:useBean id="util" class="data.huodongxinxi" scope="page" />
        <%
String data=(String)request.getParameter("data");
if(data==""){
    out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
}
else
{
    //活动主题/活动时间/活动类型/活动地点
    %>
<table border="1"style="text-align:center;">
    <tr>
        <td align="center" width=6%>活动主题</td>
        <td align="center" width=10%>活动类型</td>
        <td align="center" width=10%>活动时间</td>
        <td align="center" width=6%>活动地点</td>
    </tr>
    <%
        int i=0;
        Connection connection = util.getConnection();
        PreparedStatement preparedStatement=null;
        ResultSet rs=null;
        try {
            String sql= " select * from t0 where 活动主题 like ? or 活动类型 like ? or 活动时间 like ? or 活动地点 like ? ";
            preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1,"%"+data+"%");
            preparedStatement.setString(2,"%"+data+"%");
            preparedStatement.setString(3,"%"+data+"%");
            preparedStatement.setString(4,"%"+data+"%");
            rs=preparedStatement.executeQuery();
            while(rs.next())
            {
                i++;
    %>
    <tr>
        <td align="center"><a style="color:blue" href='chaxunall.jsp?hdzhuti0=<%=rs.getObject(1) %>'><%=rs.getObject(1)%></a> </td>
        <td align="center"><%=rs.getObject(3) %></td>
        <td align="center"><%=rs.getObject(4) %></td>
        <td align="center"><%=rs.getObject(5) %></td>
    </tr>
    <%
                }
                if(i==0)
                {
                    out.print("<script language='javaScript'> alert('没有查询到有关信息'); window.history.back(-1); </script>");
                }
            } catch (SQLException  e) {
                e.printStackTrace();
            }finally{
                util.close(rs);
                util.close(preparedStatement);
                util.close(connection);
            }
        }
    %>
</table>

<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
    <br> <input type="button" value="返回菜单" onclick="location.href='index.jsp'" /> <br>
</p>
</body>
</html>

 

posted @ 2022-10-29 11:44  sodamate  阅读(33)  评论(0编辑  收藏  举报