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

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

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

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

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

  1. private String getBasePath(final Request request) {
  2. final String contextPath = request.getContextPath();
  3. if (contextPath == null || contextPath.isEmpty()) {
  4. return "/";
  5. } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
  6. return contextPath + "/";
  7. } else {
  8. return contextPath;
  9. }
  10. }

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

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

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

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

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

  1. private String getBasePath(final Request request) {
  2. final String contextPath = request.getContextPath();
  3. if (contextPath == null || contextPath.isEmpty()) {
  4. return "/";
  5. } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
  6. return contextPath + "/";
  7. } else {
  8. return contextPath;
  9. }
  10. }

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

  1. private String getBasePath(final Request request) {
  2. final String contextPath = request.getContextPath();
  3. if (contextPath == null || contextPath.length() == 0) {
  4. return "/";
  5. } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
  6. return contextPath + "/";
  7. } else {
  8. return contextPath;
  9. }
  10. }

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

  1. private String getBasePath(final Request request) {
  2. final String contextPath = request.getContextPath();
  3. if (contextPath == null || contextPath.length() == 0) {
  4. return "/";
  5. } else if (contextPath.charAt(contextPath.length() - 1) != '/') {
  6. return contextPath + "/";
  7. } else {
  8. return contextPath;
  9. }
  10. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. protected String getRelativeURI(final Request request) throws Exception {
  2. String uri = request.getDecodedRequestURI();
  3. if (uri.contains("..")) {
  4. return null;
  5. }
  6. final String resourcesContextPath = request.getContextPath();
  7. if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
  8. if (!uri.startsWith(resourcesContextPath)) {
  9. return null;
  10. }
  11. uri = uri.substring(resourcesContextPath.length());
  12. }
  13. return uri;
  14. }

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

  1. static @NotNull
  2. String getBaseAddress(Request request) {
  3. StringBuilder buf = new StringBuilder();
  4. buf.append(request.getScheme());
  5. buf.append("://");
  6. buf.append(request.getServerName());
  7. buf.append(':');
  8. buf.append(request.getServerPort());
  9. buf.append(request.getContextPath());
  10. return buf.toString();
  11. }

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

  1. public void initialize(final Request request,
  2. final HttpServletResponseImpl servletResponse,
  3. final WebSocketMappingData mappingData) throws IOException {
  4. if (mappingData != null) {
  5. updatePaths(mappingData);
  6. } else {
  7. contextPath = request.getContextPath();
  8. }
  9. if (mappingData != null && mappingData.isGlassfish) {
  10. glassfishSupport = new GlassfishSupport(mappingData.context,
  11. mappingData.wrapper, this);
  12. } else {
  13. glassfishSupport = new GlassfishSupport();
  14. }
  15. super.initialize(request, servletResponse,
  16. new WebappContext("web-socket-ctx", contextPath));
  17. }

相关文章

Request类方法