protected class WebRequestContextFilter.WebRequestContextThreadState extends Object implements ThreadState
| 构造器和说明 |
|---|
WebRequestContextThreadState(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
bind()
Binds any state that should be made accessible during a thread's execution.
|
void |
clear()
Completely clears/removes the
ThreadContext state. |
javax.servlet.http.HttpServletRequest |
getHttpRequest() |
javax.servlet.http.HttpServletResponse |
getHttpResponse() |
WebRequestContext |
getRequestContext() |
void |
restore()
Restores a thread to its state before bind
bind was invoked. |
public WebRequestContextThreadState(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse)
public void bind()
ThreadStatetry/finally block paired with the ThreadState.restore() call to guarantee that the thread
is cleanly restored back to its original state. For example:
ThreadState state = //acquire or instantiate as necessary
try {
state.bind();
doSomething(); //execute any logic downstream logic that might need to access the state
} finally {
state.restore();
}
bind 在接口中 ThreadStatepublic void restore()
ThreadStatebind was invoked. This should typically always be
called in a finally block to guarantee that the thread is cleanly restored back to its original state
before bind's bind was called. For example:
ThreadState state = //acquire or instantiate as necessary
try {
state.bind();
doSomething(); //execute any logic downstream logic that might need to access the state
} finally {
state.restore();
}
restore 在接口中 ThreadStatepublic void clear()
ThreadStateThreadContext state. Typically this method should
only be called in special cases - it is more 'correct' to restore a thread to its previous
state than to clear it entirely.clear 在接口中 ThreadStatepublic javax.servlet.http.HttpServletRequest getHttpRequest()
public javax.servlet.http.HttpServletResponse getHttpResponse()
public WebRequestContext getRequestContext()
Copyright © 2020 nomou. All rights reserved.