本文整理匯總了Java中javax.servlet.http.HttpSessionBindingListener.valueBound方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpSessionBindingListener.valueBound方法的具體用法?Java HttpSessionBindingListener.valueBound怎麽用?Java HttpSessionBindingListener.valueBound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.http.HttpSessionBindingListener
的用法示例。
在下文中一共展示了HttpSessionBindingListener.valueBound方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAttribute
import javax.servlet.http.HttpSessionBindingListener; //導入方法依賴的package包/類
/**
* Binds an object to this session, using the name specified. If an object of
* the same name is already bound to the session, the object is replaced.
* @param name The name to which the object is bound; cannot be null.
* @param value The object to be bound.
*/
public void setAttribute(String name, Object value) {
if (!isValid())
throw new IllegalStateException(
"Method is called on an invalidated session");
if (value == null) removeAttribute(name);
else {
attributes.put(name, value);
try {
HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
listener.valueBound(new HttpSessionBindingEvent(this, name, value));
listener.notifyAll();
}
catch (ClassCastException e) { }
}
}
示例2: afterBound
import javax.servlet.http.HttpSessionBindingListener; //導入方法依賴的package包/類
protected void afterBound(String s, Object o) {
if (o instanceof HttpSessionBindingListener) {
HttpSessionBindingListener listener = (HttpSessionBindingListener) o;
HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, s, o);
listener.valueBound(event);
}
}