我是靠谱客的博主 典雅戒指,最近开发中收集的这篇文章主要介绍java removeattribute_Java HttpServletRequest.removeAttribute方法代碼示例Servlet Event Listeners,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

本文整理匯總了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

最后

以上就是典雅戒指为你收集整理的java removeattribute_Java HttpServletRequest.removeAttribute方法代碼示例Servlet Event Listeners的全部内容,希望文章能够帮你解决java removeattribute_Java HttpServletRequest.removeAttribute方法代碼示例Servlet Event Listeners所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部