?? sessionlistener.java
字號:
package com.tarena.shoppingcart.listener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import com.tarena.shoppingcart.model.Cart;
import com.tarena.shoppingcart.util.HibernateUtil;
public class SessionListener implements HttpSessionListener
{
/*
*在session被創建時向其中設置屬性cart
*/
public void sessionCreated(HttpSessionEvent event) {
Cart cart = new Cart();
event.getSession().setAttribute("cart", cart);
}
//會話銷毀前關閉數據庫的session
public void sessionDestroyed(HttpSessionEvent event) {
HibernateUtil.closeSession();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -