//JDBCUtils.java
package JDBCUtils;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;
public class JDBCUtils {
private static String driver;
private static String url;
private static String username;
private static String password;
static {
try {
ClassLoader classLoader = JDBCUtils.class.getClassLoader();
InputStream is = classLoader.getResourceAsStream("db.properties");
Properties props = new Properties();
props.load(is);
driver = props.getProperty("driver");
url = props.getProperty("url");
username = props.getProperty("username");
password = props.getProperty("password");
} catch (IOException e) {
e.printStackTrace();
}
}
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void release(Connection conn, PreparedStatement pstmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (pstmt != null) {
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
//TestJDNCUtils.java
package JDBCUtils;
import org.junit.Test;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class TestDBUtils {
@Test
public void testUpdateById() {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = JDBCUtils.getConnection();
String sql = "select * from we";
pstmt = conn.prepareStatement(sql);
ResultSet rs=pstmt.executeQuery();
while(rs.next()){
String name=rs.getString("cla");
String teacher=rs.getString("teacher");
String whe=rs.getString("whe");
System.out.println(cla+" "+teacher+" "+whe);
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
JDBCUtils.release(conn, pstmt, null);
}
}
}
//index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>登记界面</title>
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="theme1/images/favicon.png">
<!-- Custom Stylesheet -->
<link href="theme1/css/style.css" rel="stylesheet">
</head>
<body>
<!--*******************
Preloader start
********************-->
<div id="preloader">
<div class="loader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="3" stroke-miterlimit="10" />
</svg>
</div>
</div>
<!--*******************
Preloader end
********************-->
<!--**********************************
Main wrapper start
***********************************-->
<div id="main-wrapper">
<!--**********************************
Nav header start
***********************************-->
<div class="nav-header">
<div class="brand-logo">
<a href="theme1/index.html">
<b class="logo-abbr"><img src="theme1/images/logo.png" alt=""> </b>
<span class="logo-compact"><img src="theme1/images/logo-compact.png" alt=""></span>
<span class="brand-title">
<img src="theme1/images/logo-text.png" alt="">
</span>
</a>
</div>
</div>
<!--**********************************
Nav header end
***********************************-->
<!--**********************************
Header start
***********************************-->
<div class="header">
<div class="header-content clearfix">
<div class="nav-control">
<div class="hamburger">
<span class="toggle-icon"><i class="icon-menu"></i></span>
</div>
</div>
<div class="header-left">
<div class="input-group icons">
<div class="input-group-prepend">
<span class="input-group-text bg-transparent border-0 pr-2 pr-sm-3" id="basic-addon1"><i class="mdi mdi-magnify"></i></span>
</div>
<input type="search" class="form-control" placeholder="Search Dashboard" aria-label="Search Dashboard">
<div class="drop-down d-md-none">
<form action="#">
<input type="text" class="form-control" placeholder="Search">
</form>
</div>
</div>
</div>
<div class="header-right">
<ul class="clearfix">
<li class="icons dropdown"><a href="javascript:void(0)" data-toggle="dropdown">
<i class="mdi mdi-email-outline"></i>
<span class="badge gradient-1 badge-pill badge-primary">1</span>
</a>
<div class="drop-down animated fadeIn dropdown-menu">
<div class="dropdown-content-heading d-flex justify-content-between">
<span class="">1条新消息</span>
</div>
<div class="dropdown-content-body">
<ul>
<li class="notification-unread">
<a href="javascript:void()">
<img class="float-left mr-3 avatar-img" src="theme1/images/avatar/1.jpg" alt="">
<div class="notification-content">
<div class="notification-heading">妈妈</div>
<div class="notification-timestamp">8分钟前</div>
<div class="notification-text">加油</div>
</div>
</a>
</li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown"><a href="javascript:void(0)" data-toggle="dropdown">
<i class="mdi mdi-bell-outline"></i>
<span class="badge badge-pill gradient-2 badge-primary">1</span>
</a>
<div class="drop-down animated fadeIn dropdown-menu dropdown-notfication">
<div class="dropdown-content-heading d-flex justify-content-between">
<span class="">1条新消息</span>
</div>
<div class="dropdown-content-body">
<ul>
<li>
<a href="javascript:void()">
<span class="mr-3 avatar-icon bg-success-lighten-2"><i class="icon-present"></i></span>
<div class="notification-content">
<h6 class="notification-heading">周围有考试进行</h6>
<span class="notification-text">今天</span>
</div>
</a>
</li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown d-none d-md-flex">
<a href="javascript:void(0)" class="log-user" data-toggle="dropdown">
<span>English</span> <i class="fa fa-angle-down f-s-14" aria-hidden="true"></i>
</a>
<div class="drop-down dropdown-language animated fadeIn dropdown-menu">
<div class="dropdown-content-body">
<ul>
<li><a href="javascript:void()">英语</a></li>
<li><a href="javascript:void()">中文</a></li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown">
<div class="user-img c-pointer position-relative" data-toggle="dropdown">
<span class="activity active"></span>
<img src="theme1/images/user/1.png" height="40" width="40" alt="">
</div>
<div class="drop-down dropdown-profile dropdown-menu">
<div class="dropdown-content-body">
<ul>
<li>
<a href="theme1/app-profile.html"><i class="icon-user"></i> <span>个人信息</span></a>
</li>
<li>
<a href="theme1/email-inbox.html"><i class="icon-envelope-open"></i> <span>收件箱</span> <div class="badge gradient-3 badge-pill badge-primary">3</div></a>
</li>
<hr class="my-2">
<li>
<a href="theme1/page-lock.html"><i class="icon-lock"></i> <span>锁定屏幕</span></a>
</li>
<li><a href="theme1/page-login.html"><i class="icon-key"></i> <span>解锁屏幕</span></a></li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<!--**********************************
Header end ti-comment-alt
***********************************-->
<!--**********************************
Sidebar start
***********************************-->
<div class="nk-sidebar">
<div class="nk-nav-scroll">
<ul class="metismenu" id="menu">
<li class="nav-label">登记界面</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-speedometer menu-icon"></i><span class="nav-text">Dashboard</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/index.html">Home 1</a></li>
<!-- <li><a href="./index-2.html">Home 2</a></li> -->
</ul>
</li>
<li>
<a href="theme1/widgets.html" aria-expanded="false">
<i class="icon-badge menu-icon"></i><span class="nav-text">Widget</span>
</a>
</li>
<li class="nav-label">Forms</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-note menu-icon"></i><span class="nav-text">Forms</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/form-basic.html">Basic Form</a></li>
<li><a href="theme1/form-validation.html">Form Validation</a></li>
<li><a href="theme1/form-step.html">Step Form</a></li>
<li><a href="theme1/form-editor.html">Editor</a></li>
<li><a href="theme1/form-picker.html">Picker</a></li>
</ul>
</li>
<li class="nav-label">Table</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-menu menu-icon"></i><span class="nav-text">Table</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/table-basic.html" aria-expanded="false">Basic Table</a></li>
<li><a href="theme1/table-datatable.html" aria-expanded="false">Data Table</a></li>
</ul>
</li>
<li class="nav-label">Pages</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-notebook menu-icon"></i><span class="nav-text">Pages</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/page-login.html">Login</a></li>
<li><a href="theme1/page-register.html">Register</a></li>
<li><a href="theme1/page-lock.html">Lock Screen</a></li>
<li><a class="has-arrow" href="javascript:void()" aria-expanded="false">Error</a>
<ul aria-expanded="false">
<li><a href="theme1/page-error-404.html">Error 404</a></li>
<li><a href="theme1/page-error-403.html">Error 403</a></li>
<li><a href="theme1/page-error-400.html">Error 400</a></li>
<li><a href="theme1/page-error-500.html">Error 500</a></li>
<li><a href="theme1/page-error-503.html">Error 503</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!--**********************************
Sidebar end
***********************************-->
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<div class="row page-titles mx-0">
<div class="col p-md-0">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0)">功能</a></li>
<li class="breadcrumb-item active"><a href="javascript:void(0)">登记信息</a></li>
</ol>
</div>
</div>
<!-- row -->
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="form-validation">
<form class="form-valide" action="Servlet/useServlet" method="post">
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="val-square">课程名称 <span class="text-danger">*</span>
</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="val-square" name="val-square" placeholder="请输入课程名称">
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="val-confirm-count">任课老师 <span class="text-danger">*</span>
</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="val-confirm-count" name="val-confirm-count" placeholder="请输入任课教师姓名">
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="val-username">授课地点 <span class="text-danger">*</span>
</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="val-username" name="val-username" placeholder="请输入授课地点">
</div>
</div>
<!--提交按钮-->
<div class="form-group row">
<div class="col-lg-8 ml-auto">
<button type="submit" class="btn btn-primary" onclick='window.open("print.jsp")'>提交</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- #/ container -->
</div>
<!--**********************************
Content body end
***********************************-->
<!--**********************************
Footer start
***********************************-->
<div class="footer">
<div class="copyright">
<p>Copyright © Designed & Developed by <a href="https://themeforest.net/user/quixlab">Quixlab</a> 2018</p>
</div>
</div>
<!--**********************************
Footer end
***********************************-->
</div>
<!--**********************************
Main wrapper end
***********************************-->
<!--**********************************
Scripts
***********************************-->
<script src="theme1/plugins/common/common.min.js"></script>
<script src="theme1/js/custom.min.js"></script>
<script src="theme1/js/settings.js"></script>
<script src="theme1/js/gleek.js"></script>
<script src="theme1/js/styleSwitcher.js"></script>
<script src="theme1/plugins/validation/jquery.validate.min.js"></script>
<script src="theme1/plugins/validation/jquery.validate-init.js"></script>
</body>
</html>
//Main.jsp
<%@ page import="Dao.DaoCao" %>
<%@ page import="Bean.user" %>
<%@ page import="java.sql.*" %>
<%@ page import="JDBCUtils.JDBCUtils" %>
<%--
Created by IntelliJ IDEA.
User: 12140
Date: 2022/10/6
Time: 17:34
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>浏览信息界面</title>
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="theme1/images/favicon.png">
<!-- Custom Stylesheet -->
<link href="theme1/plugins/tables/css/datatable/dataTables.bootstrap4.min.css" rel="stylesheet">
<link href="theme1/css/style.css" rel="stylesheet">
</head>
<body>
<!--*******************
Preloader start
********************-->
<div id="preloader">
<div class="loader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="3" stroke-miterlimit="10" />
</svg>
</div>
</div>
<!--*******************
Preloader end
********************-->
<!--**********************************
Main wrapper start
***********************************-->
<div id="main-wrapper">
<!--**********************************
Nav header start
***********************************-->
<div class="nav-header">
<div class="brand-logo">
<a href="theme1/index.html">
<b class="logo-abbr"><img src="theme1/images/logo.png" alt=""> </b>
<span class="logo-compact"><img src="theme1/images/logo-compact.png" alt=""></span>
<span class="brand-title">
<img src="theme1/images/logo-text.png" alt="">
</span>
</a>
</div>
</div>
<!--**********************************
Nav header end
***********************************-->
<!--**********************************
Header start
***********************************-->
<div class="header">
<div class="header-content clearfix">
<div class="nav-control">
<div class="hamburger">
<span class="toggle-icon"><i class="icon-menu"></i></span>
</div>
</div>
<div class="header-left">
<div class="input-group icons">
<div class="input-group-prepend">
<span class="input-group-text bg-transparent border-0 pr-2 pr-sm-3" id="basic-addon1"><i class="mdi mdi-magnify"></i></span>
</div>
<input type="search" class="form-control" placeholder="Search Dashboard" aria-label="Search Dashboard">
<div class="drop-down d-md-none">
<form action="#">
<input type="text" class="form-control" placeholder="Search">
</form>
</div>
</div>
</div>
<div class="header-right">
<ul class="clearfix">
<li class="icons dropdown"><a href="javascript:void(0)" data-toggle="dropdown">
<i class="mdi mdi-email-outline"></i>
<span class="badge gradient-1 badge-pill badge-primary">1</span>
</a>
<div class="drop-down animated fadeIn dropdown-menu">
<div class="dropdown-content-heading d-flex justify-content-between">
<span class="">1条新消息</span>
</div>
<div class="dropdown-content-body">
<ul>
<li class="notification-unread">
<a href="javascript:void()">
<img class="float-left mr-3 avatar-img" src="images/avatar/1.jpg" alt="">
<div class="notification-content">
<div class="notification-heading">Saiful Islam</div>
<div class="notification-timestamp">08 Hours ago</div>
<div class="notification-text">Hi Teddy, Just wanted to let you ...</div>
</div>
</a>
</li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown"><a href="javascript:void(0)" data-toggle="dropdown">
<i class="mdi mdi-bell-outline"></i>
<span class="badge badge-pill gradient-2 badge-primary">1</span>
</a>
<div class="drop-down animated fadeIn dropdown-menu dropdown-notfication">
<div class="dropdown-content-heading d-flex justify-content-between">
<span class="">1条新通知</span>
</div>
<div class="dropdown-content-body">
<ul>
<li>
<a href="javascript:void()">
<span class="mr-3 avatar-icon bg-success-lighten-2"><i class="icon-present"></i></span>
<div class="notification-content">
<h6 class="notification-heading">Events near you</h6>
<span class="notification-text">Within next 5 days</span>
</div>
</a>
</li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown d-none d-md-flex">
<a href="javascript:void(0)" class="log-user" data-toggle="dropdown">
<span>English</span> <i class="fa fa-angle-down f-s-14" aria-hidden="true"></i>
</a>
<div class="drop-down dropdown-language animated fadeIn dropdown-menu">
<div class="dropdown-content-body">
<ul>
<li><a href="javascript:void()">English</a></li>
<li><a href="javascript:void()">Dutch</a></li>
</ul>
</div>
</div>
</li>
<li class="icons dropdown">
<div class="user-img c-pointer position-relative" data-toggle="dropdown">
<span class="activity active"></span>
<img src="theme1/images/user/1.png" height="40" width="40" alt="">
</div>
<div class="drop-down dropdown-profile dropdown-menu">
<div class="dropdown-content-body">
<ul>
<li>
<a href="theme1/app-profile.html"><i class="icon-user"></i> <span>Profile</span></a>
</li>
<li>
<a href="theme1/email-inbox.html"><i class="icon-envelope-open"></i> <span>Inbox</span> <div class="badge gradient-3 badge-pill badge-primary">3</div></a>
</li>
<hr class="my-2">
<li>
<a href="theme1/page-lock.html"><i class="icon-lock"></i> <span>Lock Screen</span></a>
</li>
<li><a href="theme1/page-login.html"><i class="icon-key"></i> <span>Logout</span></a></li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<!--**********************************
Header end ti-comment-alt
***********************************-->
<!--**********************************
Sidebar start
***********************************-->
<div class="nk-sidebar">
<div class="nk-nav-scroll">
<ul class="metismenu" id="menu">
<li class="nav-label">Dashboard</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-speedometer menu-icon"></i><span class="nav-text">Dashboard</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/index.html">Home 1</a></li>
<!-- <li><a href="./index-2.html">Home 2</a></li> -->
</ul>
</li>
<li class="mega-menu mega-menu-sm">
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-globe-alt menu-icon"></i><span class="nav-text">Layouts</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/layout-blank.html">Blank</a></li>
<li><a href="theme1/layout-one-column.html">One Column</a></li>
<li><a href="theme1/layout-two-column.html">Two column</a></li>
<li><a href="theme1/layout-compact-nav.html">Compact Nav</a></li>
<li><a href="theme1/layout-vertical.html">Vertical</a></li>
<li><a href="theme1/layout-horizontal.html">Horizontal</a></li>
<li><a href="theme1/layout-boxed.html">Boxed</a></li>
<li><a href="theme1/layout-wide.html">Wide</a></li>
<li><a href="theme1/layout-fixed-header.html">Fixed Header</a></li>
<li><a href="theme1/layout-fixed-sidebar.html">Fixed Sidebar</a></li>
</ul>
</li>
<li class="nav-label">Apps</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-envelope menu-icon"></i> <span class="nav-text">Email</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/email-inbox.html">Inbox</a></li>
<li><a href="theme1/email-read.html">Read</a></li>
<li><a href="theme1/email-compose.html">Compose</a></li>
</ul>
</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-screen-tablet menu-icon"></i><span class="nav-text">Apps</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/app-profile.html">Profile</a></li>
<li><a href="theme1/app-calender.html">Calender</a></li>
</ul>
</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-graph menu-icon"></i> <span class="nav-text">Charts</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/chart-flot.html">Flot</a></li>
<li><a href="theme1/chart-morris.html">Morris</a></li>
<li><a href="theme1/chart-chartjs.html">Chartjs</a></li>
<li><a href="theme1/chart-chartist.html">Chartist</a></li>
<li><a href="theme1/chart-sparkline.html">Sparkline</a></li>
<li><a href="theme1/chart-peity.html">Peity</a></li>
</ul>
</li>
<li class="nav-label">UI Components</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-grid menu-icon"></i><span class="nav-text">UI Components</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/ui-accordion.html">Accordion</a></li>
<li><a href="theme1/ui-alert.html">Alert</a></li>
<li><a href="theme1/ui-badge.html">Badge</a></li>
<li><a href="theme1/ui-button.html">Button</a></li>
<li><a href="theme1/ui-button-group.html">Button Group</a></li>
<li><a href="theme1/ui-cards.html">Cards</a></li>
<li><a href="theme1/ui-carousel.html">Carousel</a></li>
<li><a href="theme1/ui-dropdown.html">Dropdown</a></li>
<li><a href="theme1/ui-list-group.html">List Group</a></li>
<li><a href="theme1/ui-media-object.html">Media Object</a></li>
<li><a href="theme1/ui-modal.html">Modal</a></li>
<li><a href="theme1/ui-pagination.html">Pagination</a></li>
<li><a href="theme1/ui-popover.html">Popover</a></li>
<li><a href="theme1/ui-progressbar.html">Progressbar</a></li>
<li><a href="theme1/ui-tab.html">Tab</a></li>
<li><a href="theme1/ui-typography.html">Typography</a></li>
<!-- </ul>
</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-layers menu-icon"></i><span class="nav-text">Components</span>
</a>
<ul aria-expanded="false"> -->
<li><a href="theme1/uc-nestedable.html">Nestedable</a></li>
<li><a href="theme1/uc-noui-slider.html">Noui Slider</a></li>
<li><a href="theme1/uc-sweetalert.html">Sweet Alert</a></li>
<li><a href="theme1/uc-toastr.html">Toastr</a></li>
</ul>
</li>
<li>
<a href="theme1/widgets.html" aria-expanded="false">
<i class="icon-badge menu-icon"></i><span class="nav-text">Widget</span>
</a>
</li>
<li class="nav-label">Forms</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-note menu-icon"></i><span class="nav-text">Forms</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/form-basic.html">Basic Form</a></li>
<li><a href="theme1/form-validation.html">Form Validation</a></li>
<li><a href="theme1/form-step.html">Step Form</a></li>
<li><a href="theme1/form-editor.html">Editor</a></li>
<li><a href="theme1/form-picker.html">Picker</a></li>
</ul>
</li>
<li class="nav-label">Table</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-menu menu-icon"></i><span class="nav-text">Table</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/table-basic.html" aria-expanded="false">Basic Table</a></li>
<li><a href="theme1/table-datatable.html" aria-expanded="false">Data Table</a></li>
</ul>
</li>
<li class="nav-label">Pages</li>
<li>
<a class="has-arrow" href="javascript:void()" aria-expanded="false">
<i class="icon-notebook menu-icon"></i><span class="nav-text">Pages</span>
</a>
<ul aria-expanded="false">
<li><a href="theme1/page-login.html">Login</a></li>
<li><a href="theme1/page-register.html">Register</a></li>
<li><a href="theme1/page-lock.html">Lock Screen</a></li>
<li><a class="has-arrow" href="javascript:void()" aria-expanded="false">Error</a>
<ul aria-expanded="false">
<li><a href="theme1/page-error-404.html">Error 404</a></li>
<li><a href="theme1/page-error-403.html">Error 403</a></li>
<li><a href="theme1/page-error-400.html">Error 400</a></li>
<li><a href="theme1/page-error-500.html">Error 500</a></li>
<li><a href="theme1/page-error-503.html">Error 503</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!--**********************************
Sidebar end
***********************************-->
<!--**********************************
Content body start
***********************************-->
<div class="content-body">
<div class="row page-titles mx-0">
<div class="col p-md-0">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="javascript:void(0)">功能</a></li>
<li class="breadcrumb-item active"><a href="javascript:void(0)">浏览信息</a></li>
</ol>
</div>
</div>
<!-- row -->
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">信息的浏览</h4>
<div class="table-responsive">
<table class="table table-striped table-bordered zero-configuration">
<thead>
<tr>
<th>课程名称</th>
<th>教师姓名</th>
<th>授课地点</th>
</tr>
</thead>
<tbody>
<%
Connection conn=null;
PreparedStatement psmt=null;
ResultSet rs=null;
try {
conn=JDBCUtils.getConnection();
psmt=conn.prepareStatement("select * from super1");
rs=psmt.executeQuery();
String cla=(String)request.getAttribute("cla");
String teacher=(String)request.getParameter("teacher");
String whe=(String)request.getParameter("whe");
%>
<tr>
<td>${cla}</td>
<td>${teacher}</td>
<td>${whe}</td>
</tr>
<%
JDBCUtils.release(conn,psmt,rs);
} catch (SQLException e) {
throw new RuntimeException(e);
}
%>
</tbody>
<tfoot>
<tr>
<th>课程名称</th>
<th>教师姓名</th>
<th>授课地点</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- #/ container -->
</div>
<!--**********************************
Content body end
***********************************-->
<!--**********************************
Footer start
***********************************-->
<div class="footer">
<div class="copyright">
<p>Copyright © Designed & Developed by <a href="https://themeforest.net/user/quixlab">Quixlab</a> 2018</p>
</div>
</div>
<!--**********************************
Footer end
***********************************-->
</div>
<!--**********************************
Main wrapper end
***********************************-->
<!--**********************************
Scripts
***********************************-->
<script src="theme1/plugins/common/common.min.js"></script>
<script src="theme1/js/custom.min.js"></script>
<script src="theme1/js/settings.js"></script>
<script src="theme1/js/gleek.js"></script>
<script src="theme1/js/styleSwitcher.js"></script>
<script src="theme1/plugins/tables/js/jquery.dataTables.min.js"></script>
<script src="theme1/plugins/tables/js/datatable/dataTables.bootstrap4.min.js"></script>
<script src="theme1/plugins/tables/js/datatable-init/datatable-basic.min.js"></script>
</body>
</html>
//useServlet.java
package Servlet;
import Bean.useBean;
import Bean.user;
import Dao.DaoCao;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class useServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//将数据传递到jsp页面
req.setCharacterEncoding("utf-8");
resp.setCharacterEncoding("utf-8");
//从jsp页面获取数据
String cla=req.getParameter("cla");
String teacher=req.getParameter("teacher");
String whe=req.getParameter("whe");
req.setAttribute("cla",cla);
req.setAttribute("teacher",teacher);
req.setAttribute("whe",whe);
req.getRequestDispatcher("print.jsp").forward(req,resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req,resp);
}
}
标签:java,String,一下,req,Error,import,优化,conn
From: https://www.cnblogs.com/liuzijin/p/16776941.html