本文整理匯總了Java中javax.servlet.http.HttpServletRequest.removeAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.removeAttribute方法的具體用法?Java HttpServletRequest.removeAttribute怎麽用?Java HttpServletRequest.removeAttribute使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.http.HttpServletRequest的用法示例。
在下文中一共展示了HttpServletRequest.removeAttribute方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: exposeModelAsRequestAttributes
點讚 3
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
* Expose the model objects in the given map as request attributes.
* Names will be taken from the model Map.
* This method is suitable for all resources reachable by {@link javax.servlet.RequestDispatcher}.
* @param model Map of model objects to expose
* @param request current HTTP request
*/
protected void exposeModelAsRequestAttributes(Map model, HttpServletRequest request) throws Exception {
for (Map.Entry entry : model.entrySet()) {
String modelName = entry.getKey();
Object modelValue = entry.getValue();
if (modelValue != null) {
request.setAttribute(modelName, modelValue);
if (logger.isDebugEnabled()) {
logger.debug("Added model object '" + modelName + "' of type [" + modelValue.getClass().getName() +
"] to request in view");
}
}
else {
request.removeAttribute(modelName);
if (logger.isDebugEnabled()) {
logger.debug("Removed model object '" + modelName +
"' from request in view");
}
}
}
}
開發者ID:devefx,項目名稱:validator-web,代碼行數:28,
示例2: runCallbacks
點讚 3
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void runCallbacks(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
{
List callbacks = (List) httpRequest.getAttribute(CALLBACKS_KEY);
httpRequest.removeAttribute(CALLBACKS_KEY);
if( callbacks != null )
{
// Run them in reverse, don't let one callback stop the rest from happening
for( int i = callbacks.size() - 1; i >= 0; i-- )
{
try
{
callbacks.get(i).afterServlet(httpRequest, httpResponse);
}
catch( Exception e )
{
LOGGER.error("Error running callback", e);
}
}
}
}
開發者ID:equella,項目名稱:Equella,代碼行數:22,
示例3: processRequest
點讚 2
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("
");out.println("
Servlet Event Listeners");out.println("");
out.println("
");out.println("
Servlet Event Listeners
");out.println("
Setting, updating, and removing ServletContext Attributes
");request.getServletContext().setAttribute("attribute1", "attribute-value1");
request.getServletContext().setAttribute("attribute1", "attribute-updated-value1");
request.getServletContext().removeAttribute("attribute1");
out.println("done");
out.println("
Setting, updating, and removing HttpSession Attributes
");request.getSession(true).setAttribute("attribute1", "attribute-value1");
reques