org.kohsuke.stapler.StaplerRequest.getServletContext()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(65)

本文整理了Java中org.kohsuke.stapler.StaplerRequest.getServletContext()方法的一些代码示例,展示了StaplerRequest.getServletContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getServletContext()方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getServletContext

StaplerRequest.getServletContext介绍

[英]Returns the ServletContext object given to the stapler dispatcher servlet.
[中]返回给定给订书机调度器servlet的ServletContext对象。

代码示例

代码示例来源:origin: org.kohsuke.stapler/stapler

private ServletContext getContext(HttpServletRequest req) {
    return ((StaplerRequest)req).getServletContext();
  }
};

代码示例来源:origin: stapler/stapler

private ServletContext getContext(HttpServletRequest req) {
    return ((StaplerRequest)req).getServletContext();
  }
};

代码示例来源:origin: stapler/stapler

public ServletContext getServletContext() {
  return getRequest().getServletContext();
}

代码示例来源:origin: stapler/stapler

public JellyBuilder(JellyContext context,XMLOutput output) {
  this.context = context;
  this.output = output;
  this.request = Stapler.getCurrentRequest();
  this.adjunctManager = AdjunctManager.get(request.getServletContext());
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

/**
 * Obtains the instance associated with the current request of the given {@link StaplerRequest}.
 *
 * <p>
 * This method is handy when the caller already have the request object around,
 * so that we can save {@link Stapler#getCurrentRequest()} call.
 */
public static AdjunctsInPage get(StaplerRequest request) {
  AdjunctsInPage aip = (AdjunctsInPage) request.getAttribute(KEY);
  if(aip==null)
    request.setAttribute(KEY,aip=new AdjunctsInPage(AdjunctManager.get(request.getServletContext()),request));
  return aip;
}

代码示例来源:origin: stapler/stapler

/**
 * Obtains the instance associated with the current request of the given {@link StaplerRequest}.
 *
 * <p>
 * This method is handy when the caller already have the request object around,
 * so that we can save {@link Stapler#getCurrentRequest()} call.
 */
public static AdjunctsInPage get(StaplerRequest request) {
  AdjunctsInPage aip = (AdjunctsInPage) request.getAttribute(KEY);
  if(aip==null)
    request.setAttribute(KEY,aip=new AdjunctsInPage(AdjunctManager.get(request.getServletContext()),request));
  return aip;
}

代码示例来源:origin: stapler/stapler

protected void exportVariables(StaplerRequest req, StaplerResponse rsp, Script script, Object it, JellyContext context) {
  Enumeration en = req.getAttributeNames();
  // expose request attributes, just like JSP
  while (en.hasMoreElements()) {
    String name = (String) en.nextElement();
    context.setVariable(name,req.getAttribute(name));
  }
  context.setVariable("request",req);
  context.setVariable("response",rsp);
  context.setVariable("it",it);
  ServletContext servletContext = req.getServletContext();
  context.setVariable("servletContext",servletContext);
  context.setVariable("app",servletContext.getAttribute("app"));
  // property bag to store request scope variables
  context.setVariable("requestScope",context.getVariables());
  // this variable is needed to make "jelly:fmt" taglib work correctly
  context.setVariable("org.apache.commons.jelly.tags.fmt.locale",req.getLocale());
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

protected void exportVariables(StaplerRequest req, StaplerResponse rsp, Script script, Object it, JellyContext context) {
  Enumeration en = req.getAttributeNames();
  // expose request attributes, just like JSP
  while (en.hasMoreElements()) {
    String name = (String) en.nextElement();
    context.setVariable(name,req.getAttribute(name));
  }
  context.setVariable("request",req);
  context.setVariable("response",rsp);
  context.setVariable("it",it);
  ServletContext servletContext = req.getServletContext();
  context.setVariable("servletContext",servletContext);
  context.setVariable("app",servletContext.getAttribute("app"));
  // property bag to store request scope variables
  context.setVariable("requestScope",context.getVariables());
  // this variable is needed to make "jelly:fmt" taglib work correctly
  context.setVariable("org.apache.commons.jelly.tags.fmt.locale",req.getLocale());
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法