org.glassfish.grizzly.http.server.Request.getContextPath()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(184)

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

Request.getContextPath介绍

[英]Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For HttpHandlers in the default (root) context, this method returns "". The container does not decode this string.
[中]返回请求URI中指示请求上下文的部分。在请求URI中,上下文路径总是排在第一位。路径以“/”字符开头,但不以“/”字符结尾。对于默认(根)上下文中的HttpHandler,此方法返回“”。容器不解码此字符串。

代码示例

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

private boolean containsContextPath(Request request) {
  return request.getContextPath() != null && request.getContextPath().length() > 0;
}

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

private String getBasePath(final Request request) {
  final String contextPath = request.getContextPath();
  if (contextPath == null || contextPath.isEmpty()) {
    return "/";
  } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
    return contextPath + "/";
  } else {
    return contextPath;
  }
}

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

final String resourcesContextPath = request.getContextPath();
System.out.println("context: " + resourcesContextPath);
if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {

代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-grizzly2-http

private boolean containsContextPath(Request request) {
  return request.getContextPath() != null && request.getContextPath().length() > 0;
}

代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-grizzly2-http

private String getBasePath(final Request request) {
  final String contextPath = request.getContextPath();
  if (contextPath == null || contextPath.isEmpty()) {
    return "/";
  } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
    return contextPath + "/";
  } else {
    return contextPath;
  }
}

代码示例来源:origin: com.sun.jersey/jersey-grizzly2

private String getBasePath(final Request request) {
  final String contextPath = request.getContextPath();
  if (contextPath == null || contextPath.length() == 0) {
    return "/";
  } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
    return contextPath + "/";
  } else {
    return contextPath;
  }
}

代码示例来源:origin: jersey/jersey-1.x

private String getBasePath(final Request request) {
  final String contextPath = request.getContextPath();
  if (contextPath == null || contextPath.length() == 0) {
    return "/";
  } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
    return contextPath + "/";
  } else {
    return contextPath;
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-http-server

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

protected String getRelativeURI(final Request request) throws Exception {
  String uri = request.getDecodedRequestURI();
  if (uri.contains("..")) {
    return null;
  }
  final String resourcesContextPath = request.getContextPath();
  if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
    if (!uri.startsWith(resourcesContextPath)) {
      return null;
    }
    uri = uri.substring(resourcesContextPath.length());
  }
  return uri;
}

代码示例来源:origin: javaee/grizzly

static @NotNull
String getBaseAddress(Request request) {
  StringBuilder buf = new StringBuilder();
  buf.append(request.getScheme());
  buf.append("://");
  buf.append(request.getServerName());
  buf.append(':');
  buf.append(request.getServerPort());
  buf.append(request.getContextPath());
  return buf.toString();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

public void initialize(final Request request,
    final HttpServletResponseImpl servletResponse,
    final WebSocketMappingData mappingData) throws IOException {
  
  if (mappingData != null) {
    updatePaths(mappingData);
  } else {
    contextPath = request.getContextPath();
  }
  
  if (mappingData != null && mappingData.isGlassfish) {
    glassfishSupport = new GlassfishSupport(mappingData.context,
        mappingData.wrapper, this);
  } else {
    glassfishSupport = new GlassfishSupport();
  }
  
  super.initialize(request, servletResponse,
      new WebappContext("web-socket-ctx", contextPath));
}

相关文章

微信公众号

最新文章

更多

Request类方法