基于MVC的JSP学生管理系统(目前只可以浏览数据)(1)
//index.jsp的源码
//
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
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>
<base href="<%=basePath%>">
<title>登陆界面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body><br>
<form method="get" action="LoginClServlet" name="aa"><div align="center">
</div><p align="center"> 用户名 <input type="text" name="username">
</p><p align="center"> 密 码<input type="password" name="password"></p><div align="center">
</div><p align="center"> <input type="reset" value="重置" name="button2">
<input type="submit" value="确定" name="button1"> </p>
</form></body>
</html>
//com.xinxi.model包下的文件
ConnDB.java的代码
//
package com.xinxi.model;
//得到数据库的连接
import java.sql.*;
public class ConnDB {
private Connection ct=null;
public Connection getConn(){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
ct=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=djdb","sa","dongjun");
}catch(Exception ex){
ex.printStackTrace();
}return ct;
}
}
//
//UserBean.java的代码