ssm重新开发计科院新闻网站

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>西南石油大学-计算机科学学院</title>
    <link rel="stylesheet" type="text/css" href="Style01.css">
    <link rel="stylesheet" type="text/css" href="css/Iframe.css" />
     
    <script type="text/javascript">
        function a(){
            /*if(""==${sessionScope.Imagenews0Name}){
                document.getElementById("reselect").click();
            }*/
            //alert("你好");
            if(${empty sessionScope.Imagenews0Name}){
                document.getElementById("reselect").click();
            }
        }
    </script>
  </head>
  
<body onload="a()">

<!-- FFFFFFFFF -->
<div style="float:left;margin-left:10px">
<form action="Select" method="get" class="add_cp">
    <button type="submit" id="reselect">页面刷新</button>
</form>
</div>
<div style="float:left;margin-left:20px">
    <p class="add_cp"><button onclick="window.location.href='login.html'">新闻管理</button></p>
</div>

<!-- 居中显示 -->
<div style="display: block; margin: 0 auto; width: 60%; background: #fff;">
<!-- 顶部及搜索 -->
<div class="divTop">
    <div class="divSearch">
    <input type="text" placeholder="请输入关键词搜索">
    <input type="submit" value="搜索">
    </div>
</div>

<!-- 导航 -->
<div class="Guide">
    <ul class="ul1">
        <li class="li1"><a href="#">网站首页</li>
        <div class="dropDown">
            <a href="#" class="dropBtn">学院概况</a>
            <div class="dropDown-content">
                <a href="#">学院简介</a>
                <a href="#">学院领导</a>
                <a href="#">组织机构</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">本科生教育</a>
            <div class="dropDown-content">
                <a href="#">计算机科学与技术专业</a>
                <a href="#">软件工程专业</a>
                <a href="#">网络工程专业</a>
                <a href="#">物联网工程专业</a>
                <a href="#">信息管理与信息系统专业</a>
                <a href="#">网络空间安全专业</a>
                <a href="#">数据科学与大数据技术专业</a>
                <a href="#">对外人才合作培养项目</a>
                <a href="#">考试信息</a>
                <a href="#">选课重修信息</a>
                <a href="#">通知公告</a>
                <a href="#">资料下载</a>
                <a href="#">公选课教师视频</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">研究生教育</a>
            <div class="dropDown-content">
                <a href="#">招生简章</a>
                <a href="#">计算机科学与技术一级学科</a>
                <a href="#">软件工程一级学科</a>
                <a href="#">网络空间安全一级学科</a>
                <a href="#">研究生导师</a>
                <a href="#">研究生奖助体系</a>
                <a href="#">通知公告</a>
                <a href="#">资料下载</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">师资队伍</a>
            <div class="dropDown-content">
                <a href="#">教授</a>
                <a href="#">副教授</a>
                <a href="#">讲师</a>
                <a href="#">实验人员</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">科学研究</a>
            <div class="dropDown-content">
                <a href="#">科研团队</a>
                <a href="#">科研平台</a>
                <a href="#">科研成果</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">学生工作</a>
            <div class="dropDown-content">
                <a href="#">工作动态</a>
                <a href="#">通知公告</a>
                <a href="#">课外创新实践</a>
                <a href="#">毕业生就业</a>
                <a href="#">心灵之窗</a>
                <a href="#">青春风采</a>
                <a href="#">资料下载</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">招生工作</a>
            <div class="dropDown-content">
                <a href="#">学院介绍</a>
                <a href="#">毕业生就业去向</a>
                <a href="#">优秀毕业生简介</a>
                <a href="#">学生获奖</a>
                <a href="#">精英校友介绍</a>
                <a href="#">招生工作宣传报道</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">实验中心</a>
            <div class="dropDown-content">
                <a href="#">中心简介</a>
                <a href="#">实验分室</a>
                <a href="#">规章制度</a>
                <a href="#">资料下载</a>
                <a href="#">开放预约</a>
            </div>
        </div>
        <div class="dropDown">
            <a href="#" class="dropBtn">党建之窗</a>
            <div class="dropDown-content">
                <a href="#">党建动态</a>
                <a href="#">学习园地</a>
                <a href="#">党务政务公开</a>
                <a href="#">资料下载</a>
            </div>
        </div>
    </ul>
</div>
<br>
<!-- 滚动图片(暂时静态) -->
<div class="divPicture">
    <a href="#"><img alt="welcome" src="images/welcome.jpg"></a>
</div>

<!-- 文字新闻版块 -->
<div style="width:974px;height:970px;background-color:white;">
    <!-- 图片新闻 -->
    <div class="q1">
        <div class="p1">
            <div class="t1">
                图片新闻
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <div id="sp">
            <a><img alt="chat" src="images/chat.jpg" style="width:350px;width:300px"></a>
        </div>
        <p>
            <ul>
                <li class="li2"><a href="#">${sessionScope.Imagenews0Name}</a></li>
                <li class="li2"><a href="#">${sessionScope.Imagenews1Name}</a></li>
                <li class="li2"><a href="#">${sessionScope.Imagenews2Name}</a></li>
                <li class="li2"><a href="#">${sessionScope.Imagenews3Name}</a></li>
                <li class="li2"><a href="#">${sessionScope.Imagenews4Name}</a></li>
                <li class="li2"><a href="#">${sessionScope.Imagenews5Name}</a></li>
            </ul>
        </p>
    </div>
    <!-- 空行 -->
    <div class="q"></div>
    <!-- 学术交流 -->
    <div class="q2">
        <div class="p2">
            <div class="t1">
                学术交流
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <p>
            <ul>
                <li class="li2"><a href="#">基于滑动窗口和模糊c-均</a></li>
                <li class="li2"><a href="#">基于三支决策的广义代价敏</a></li>
                <li class="li2"><a href="#">人工智能+:视界充满AI</a></li>
                <li class="li2"><a href="#">零行列式策略及其网络演化动力学</a></li>
                <li class="li2"><a href="#">视频遇上云服务</a></li>
                <li class="li2"><a href="#">计科院关于举行2018年校庆论文报告会的通知</a></li>
            </ul>
        </p>
    </div>
    
    <!-- 新闻速递 -->
    <div class="q1">
        <div class="p1">
            <div class="t1">
                新闻速递
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <p>
            <ul>
                <li class="li2"><a href="#">计算机科学学院分年级召开</a></li>
                <li class="li2"><a href="#">学院召开教职工大会学习传达中层干部大会精神 部署学院学期工作</a></li>
                <li class="li2"><a href="#">计科院工会组织学院女教职工庆祝第109个“三八妇女节”</a></li>
                <li class="li2"><a href="#">学术讲座——人工智能改变我们的未来生活</a></li>
                <li class="li2"><a href="#">计算机科学学院各年级辅导员集中走访学生寝室</a></li>
                <li class="li2"><a href="#">学院召开2018年度领导班子民主生活会</a></li>
            </ul>
        </p>
    </div>
    <!-- 空行 -->
    <div class="q"></div>
    <!-- 党建动态 -->
    <div class="q2">
        <div class="p2">
            <div class="t1">
                党建动态
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <p>
            <ul>
                <li class="li3"><a href="#">学院召开党委中心组学习会暨党</a></li>
                <li class="li3"><a href="#">学院召开教职工大会学习传达中层...</a></li>
                <li class="li3"><a href="#">学院召开2018年领导班子民主生...</a></li>
                <li class="li3"><a href="#">刘翔同志任计算机科学学院党委副...</a></li>
                <li class="li3"><a href="#">学院党委组织师生收看庆祝改革开...</a></li>
                <li class="li3"><a href="#">【审核评估】学院召开本科教学工...</a></li>
                <li class="li3"><a href="#">【聚焦评估】学院召开本科教学工...</a></li>
                <li class="li3"><a href="#">学院党委开展迎校庆主题党日活动</a></li>
            </ul>
        </p>
    </div>
    
    <!-- 通知公告 -->
    <div class="q1" style="height:350px;">
        <div class="p1">
            <div class="t1">
                通知公告
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <p>
            <ul>
                <li class="li2"><a href="#">自组团出访前公示信息表(彭博)</a></li>
                <li class="li2"><a href="#">计算机科学学院2019年春季学期开学教学准备及检查工作实施方案</a></li>
                <li class="li2"><a href="#">西南石油大学计算机科学学院关于举行学院2019年春季田径运动会的通知</a></li>
                <li class="li2"><a href="#">2018年秋季学期期末考试情况总结</a></li>
                <li class="li2"><a href="#">计算机科学学院2018年度教职工考核优秀名单公示</a></li>
                <li class="li2"><a href="#">国际学术会议(ICCIS2019)征稿通知</a></li>
                <li class="li2"><a href="#">计算机科学学院领导班子2018年度民主生活会征求意见</a></li>
                <li class="li2"><a href="#">关于表彰计算机科学学院2018-2019学年秋季学期“最美寝室”的通知</a></li>
            </ul>
        </p>
    </div>
    <!-- 空行 -->
    <div class="q"></div>
    <!-- 专题列表 -->
    <div class="q2" style="height:350px;">
        <div class="p2">
            <div class="t1">
                专题列表
            </div>
            <div class="t2">
                <a href="#"><img alt="more" src="images/more.png"></a>
            </div>
        </div>
        <p>
            <ul>
                <li class="li3"><a href="#">中美联合高性能和大数据实验室</a></li>
                <li class="li3"><a href="#">石油工程计算机模拟技术重点实验室</a></li>
                <li class="li3"><a href="#">思科网络技术学院教师培训中心</a></li>
            </ul>
        </p>
    </div>
</div>
</div>
<!-- 底部 -->
    <div style="width:100%;height:70px;background-color:#224B77;color: white;text-align: center;line-height:70px;">
        Copyright© 2018 All Rights Reserved. 西南石油大学计算机科学学院
    </div>
</body>
</html>

index.jsp
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
</head>

<body style="background:#fff">
<div class="nav_top">
    <div class="nav_tcon">
        <div class="logoimg"><img src="images/logo.png" /></div>
        <div class="logotitle">
            <span>新闻后台</span>
            <p>News</p>
        </div>
        <div class="logoname">账号登录</div>
    </div>
</div>
<div class="logo_content">
    <div class="logo_ccon">
        <img class="logobei" src="images/logobei.png" />
        <form action="Login01" method="get">
            <div class="logo_enter">
            <span style="border-bottom:solid 1px #cfcfcf">请使用工作账号进行登陆</span>
            <span>登录名:</span>
            <input class="use_name" type="text" name="uname" placeholder="tom" />
            <span>登录密码:<a href="index.html">忘记登录密码?</a></span>
            <input class="use_password" type="password" name="upassword" placeholder="123" />
            <button type="submit">登&nbsp;&nbsp;录</button>
            <img class="logo_ewm" src="images/ewm.png" />
            <div class="logo_zc"><a href="index.html">没有账号?</a></div>
        </div>
        </form>
    </div>
</div>
<div class="down_info">
    <div class="information">
        <a href="#">关于我们</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">联系我们</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#">法律声明</a>
    </div>
    <p>新闻后台&nbsp;&nbsp;&nbsp;&nbsp;厦门石脉科技</p>
    <p style="font-size:12px">2015  Stonechat.com版权所有ICP证:鹭B2-22000000    </p>
    <img style="margin-top:5px" src="images/downbq.png" />
</div>
</body>
</html>

login.html
login.html
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新闻管理</title>
<link rel="stylesheet" type="text/css" href="css/Iframe.css" />
<link rel="stylesheet" href="utilLib/bootstrap.min.css" type="text/css" media="screen" />
</head>
  
<body>
<span class="cp_title">新闻管理</span>
<div class="add_cp">
    <a href="Insert.html">+添加新闻</a>
    <a href="index.jsp" style="margin-left:40px">返回主页</a>
    <a href="./Select2" style="margin-left:40px">刷新界面</a>
</div>

<div class="table_con">
    <table>
        <tr class="tb_title">
            <td width="10%">ID</td>
            <td width="30%">新闻名</td>
            <td width="26%">操作</td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews0ID}</td>
            <td width="30%">${sessionScope.Imagenews0Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews0ID}"}>
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews1ID}</td>
            <td width="30%">${sessionScope.Imagenews1Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews1ID}"}>
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews2ID}</td>
            <td width="30%">${sessionScope.Imagenews2Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews2ID}"}>
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews3ID}</td>
            <td width="30%">${sessionScope.Imagenews3Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews3ID}">
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews4ID}</td>
            <td width="30%">${sessionScope.Imagenews4Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews4ID}">
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
        <tr>
            <td width="10%">${sessionScope.Imagenews5ID}</td>
            <td width="30%">${sessionScope.Imagenews5Name}</td>
            <td width="26%">
                <input class="bj_btn" type="button" value="编辑" />
                <form action="Delete">
                    <input type="hidden" name="newsid" value="${sessionScope.Imagenews5ID}">
                    <input class="del_btn" type="submit" value="删除" />
                </form>
            </td>
        </tr>
    </table>
</div>
</body>
</html>

MyJsp.jsp
MyJsp.jsp
package com.b;

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

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.a.DBHelper;
import com.a.NewsInfo;

@WebServlet("/Select")
public class Select extends HttpServlet {

    /**
         * The doGet method of the servlet. <br>
         *
         * This method is called when a form has its tag value method equals to get.
         * 
         * @param request the request send by the client to the server
         * @param response the response send by the server to the client
         * @throws ServletException if an error occurred
         * @throws IOException if an error occurred
         */
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置请求和响应的字符集编码
        response.setContentType("text/html; charset=UTF-8");
        request.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter(); //获得输出流
        
        /*
        //数据库连接
        DBHelper dbhelper=new DBHelper();
        dbhelper.connect();
        //执行6次查询
        String[] newstime=new String[]{"imagenews","academicexchange","newsnow","partyactive","notice","spetiallist"};
        for(int time=0;time<newstime.length;time++){
            String sql="select * from "+newstime[time];
            dbhelper.select(sql);
            List<NewsInfo> newsall=dbhelper.myselect();
            
            for(int i=0;i<newsall.size();i++){
                NewsInfo Imagenews = newsall.get(i);
                request.getSession().setAttribute(newstime[time]+i+"ID", Imagenews.getId());
                request.getSession().setAttribute(newstime[time]+i+"Name", Imagenews.getName());
            }
        }
        */
        
        for(int q=0;q<6;q++){
            if(null!=request.getSession().getAttribute("Imagenews"+q+"ID")){
                request.getSession().removeAttribute("Imagenews"+q+"ID");
                request.getSession().removeAttribute("Imagenews"+q+"Name");
            }
        }
        
        
        DBHelper dbhelper=new DBHelper();
        dbhelper.connect();
        String sql="select * from imagenews";
        dbhelper.select(sql);
        
        List<NewsInfo> newsall=dbhelper.myselect();
        for(int i=0;i<newsall.size();i++){
            NewsInfo Imagenews = newsall.get(i);
            request.getSession().setAttribute("Imagenews"+i+"ID", Imagenews.getId());
            request.getSession().setAttribute("Imagenews"+i+"Name", Imagenews.getName());
        }
        
        dbhelper.close();
        
        response.sendRedirect("index.jsp");
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}

Select.java
Select.java

 

 

 

posted @ 2019-05-19 21:01  楼南  阅读(229)  评论(0编辑  收藏  举报