烟台学院毕业设计(论文) 第22页
参考文献
[1] 聂哲. Java面向对象程序设计[M].北京:高等教育出版社,2008,第2版:33-35 [2] 张海藩.软件工程导论[M].北京:清华大学出版社,2008,第5版:15-20 [3] 朱福喜,黄昊.Java项目开发与毕业设计指导[M].北京:清华大学出版社,2008,20-40
[4] 印昊.JAVA与面向对象程序设计[M].北京:高等教育出版社,2004,61-67 [5] 刘永勤.成人高校教学档案开发利用的现实意义[J].2008(3)
[6] 袁海燕. JAVA应用程序设计100例[M].北京:人民邮电出版社,2005,46-49 [7] 薛鹤娟.基于WEB的大学选课系统分析[J].希望月报(上半月),2007(11) [8] 耿祥义.Java课程设计[M].北京:清华大学出版社, 2004, 66-68
[9] Soren Lauesen.Software Requirements Styles and Techniques[M]. BeiJing: Publishing House of Electronics Industry,2002,25-90.
[10] 萨师煊,王 珊. 数据库系统概论[M].北京:高等教育出版社.1997,91-132. [12] 苏林忠、冀翼. 基于JSP技术的动态WEB开发[J].河南师范大学学报(自然科学版), 2003,31(3):94-97.
[13] 程文.基于JSP开发动态网站的设计与实现[J].现代计算机,2002,总第149期:47-50.
[14] Hans Bergsten. JavaServer Pages_2nd Edition[M]. O'Reilly, August 2002,1-500. [15] 邱旭东,刘文浩.基于JSP的MVC开发模式研究及应用[J].中国科学信息技术2006. 12-13.
烟台学院毕业设计(论文) 第23页
附 录
附录
1)连接数据库实现:
主要实现代码有: /** *
* @title getConnection * @description 连接数据库 * @author wang_dong * @create_date Jan 3, 2014 * @return connection */
public static final Connection getConnection() {
Connection connection = null; try {
Class.forName(connection = DriverManager
.getConnection(
&autoReconnect=true }
connection.setAutoCommit(false);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) { }
return connection;
e.printStackTrace();
/**
*
* @title close
烟台学院毕业设计(论文) 第24页
* @description 关闭数据库 * @author wang_dong * @create_date Jan 3, 2014 * @param connection * 数据库连接 * @param statement
* 数据库操作对象 * @param resultSet * 结果集 */
public static final void close(Connection connection, Statement statement, }
ResultSet resultSet) {
try {
if (resultSet != null) { }
if (statement != null) { }
if (connection != null) { }
connection.close(); connection = null; statement.close(); statement = null; resultSet.close(); resultSet = null;
} catch (SQLException e) { }
e.printStackTrace();
此段代码就是其中一个管理员登录查询数据库的实现函数。主要就是通过调用houses.Dao层的数据库操作函数进行查询操作。用loginCheck()方法来判断查询结果
烟台学院毕业设计(论文) 第25页
是否为空。在这个编程中加入了抛异常的语句,目的是为了让代码更加健壮、安全。
动作方法实现:
这就是struts里面的action,它的作用主要是调用数据库层的函数,对于页面获取的数据进行处理和操作。
public String checkLogin()
{
Admin_account_serviceImpl admin_account_service= new
Admin_account_serviceImpl(); //验证管理员登录
if(this.check.equals(
me, this.pwd))
{
request=ServletActionContext.getRequest(); HttpSession sess = request.getSession(); sess.setAttribute(
String user = admin_account_service.admin_name(this.loginname); sess.setAttribute(
//sess.setAttribute( }
return
这就是其中一个action方法的实现。它主要普通java类继承ActionSupport类,将页面中传过来的值注入到java类中,通过struts管理action类和页面请求动作,首先得到一个Httpsession对象,通过admin_account_service对象调用实现层方法,实现的是将页面数据在数据库中进行查表,得到一个user对象,然后将user放入session中,返回一个admin,admin是在struts中配置跳转路径,跳到相应的jsp页面,在页面中通过sess.getAttribute(得到值,在页面上做相应的显示。
/*
*
* @title userLogin @author wang_dong * * @see
烟台学院毕业设计(论文) 第26页
com.icms.user.dao.UserLoginDao#userLogin(com.icms.user.action.form.UserInforForm)
*/
public int userLogin(UserInforForm userInforForm) { }
String userLoginName = userInforForm.getUserLoginName(); String userLoginPwd = userInforForm.getUserLoginPwd(); int userRole = userInforForm.getUserPermissionId(); String sql =
+ userLoginName + +
try {
connection = HelperClass.getConnection();
preparedStatement = connection.prepareStatement(sql); resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { }
flag = 1;
} catch (Exception e) {
e.printStackTrace();
} finally { } return flag;
HelperClass.close(connection, preparedStatement, resultSet);