?? resourceinitlistener.java
字號:
/**
* 作者: 佟勁緯 創建日期: 2006-1-10
*
* QQ: 532443423 Email: TJW_7@163.com
*/
package com.tjw.guestbook.listener;
import javax.servlet.*;
import com.tjw.guestbook.database.*;
import com.tjw.guestbook.model.*;
public class ResourceInitListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent init) {
ServletContext application = init.getServletContext();
String driverClass = application.getInitParameter("driverClass");
String jdbcURL = application.getInitParameter("jdbcURL");
ConDatabase dataSource = new ConDatabase();
try {
dataSource.setDriver(driverClass, jdbcURL);
application.setAttribute("dataSource", dataSource);
} catch(ClassNotFoundException e) {
e.printStackTrace();
}
UserRegisterBean userRegister = new UserRegisterBean();
userRegister.setDataSource(dataSource);
application.setAttribute("userRegister", userRegister);
GuestBookManagerBean gbmanager = new GuestBookManagerBean();
gbmanager.setDataSource(dataSource);
application.setAttribute("gbmanager", gbmanager);
}
public void contextDestroyed(ServletContextEvent destroy) {
ServletContext application = destroy.getServletContext();
application.removeAttribute("conDatabase");
application.removeAttribute("userRegister");
application.removeAttribute("GBManager");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -