Package org.springframework.web.context.request

Examples of org.springframework.web.context.request.ServletRequestAttributes


            request.addParameter(param.name, param.value);
        }

        request.setPathInfo(null);

      ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
      RequestContextHolder.setRequestAttributes(requestAttributes);

        chain = this.hm.getHandler(request);
    }
View Full Code Here


        // clear routes from the static Router
        Router.clear();
      // clear RequestContextHolder from previous tests
      MockHttpServletRequest request = new MockHttpServletRequest("GET","http://localhost/");
      request.addHeader("host", "localhost");
      ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
      RequestContextHolder.setRequestAttributes(requestAttributes);
    }
View Full Code Here

        MockHttpServletRequest request = new MockHttpServletRequest("GET", "/reverse-routing");
        request.addHeader("host","example.org");
        request.setContextPath(contextPath);
        request.setServletPath(servletPath);

      ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
      RequestContextHolder.setRequestAttributes(requestAttributes);

        this.requestAdapter = HTTPRequestAdapter.parseRequest(request);
    }
View Full Code Here

    trace.put("path", request.getRequestURI());
    trace.put("headers", allHeaders);
    Throwable exception = (Throwable) request
        .getAttribute("javax.servlet.error.exception");
    if (exception != null && this.errorAttributes != null) {
      RequestAttributes requestAttributes = new ServletRequestAttributes(request);
      Map<String, Object> error = this.errorAttributes.getErrorAttributes(
          requestAttributes, true);
      trace.put("error", error);
    }
    return trace;
View Full Code Here

    public static final String TEMP_DIR = System.getProperty("java.io.tmpdir") + "/spring-webmvc-rythm";
   
  public static HttpServletRequest getCurrentRequest(){
      try{
        final ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
        return attr.getRequest();
      } catch (IllegalStateException e){
          return null;
      }
  }
View Full Code Here

        CommitMonitor monitor = findRequestContext(requestContext, SimpleRequestContext.class);
        return assertNotNull(monitor, "no monitor");
    }

    private void setupSpringWebEnvironment(HttpServletRequest request) {
        ServletRequestAttributes attributes = new ServletRequestAttributes(request);
        LocaleContextHolder.setLocale(request.getLocale(), threadContextInheritable);
        RequestContextHolder.setRequestAttributes(attributes, threadContextInheritable);

        getLogger().debug("Bound request context to thread: {}", request);
    }
View Full Code Here

    /**
     * 注册spring <code>ServletRequestAttributes</code>中的析构回调方法,这些方法将在request
     * context被提交之后依次调用。
     */
    public static void registerRequestDestructionCallback(String name, Runnable callback) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        attributes.registerDestructionCallback(name, callback, RequestAttributes.SCOPE_REQUEST);
    }
View Full Code Here

        cleanupSpringWebEnvironment(requestContext.getRequest());
        RequestContextUtil.removeRequestContext(requestContext.getRequest());
    }

    private void setupSpringWebEnvironment(HttpServletRequest request) {
        ServletRequestAttributes attributes = new ServletRequestAttributes(request);
        LocaleContextHolder.setLocale(request.getLocale(), threadContextInheritable);
        RequestContextHolder.setRequestAttributes(attributes, threadContextInheritable);

        getLogger().debug("Bound request context to thread: {}", request);
    }
View Full Code Here

    /**
     * 注册spring <code>ServletRequestAttributes</code>中的析构回调方法,这些方法将在request
     * context被提交之后依次调用。
     */
    public static void registerRequestDestructionCallback(String name, Runnable callback) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        attributes.registerDestructionCallback(name, callback, RequestAttributes.SCOPE_REQUEST);
    }
View Full Code Here

        cleanupSpringWebEnvironment(requestContext.getRequest());
        RequestContextUtil.removeRequestContext(requestContext.getRequest());
    }

    private void setupSpringWebEnvironment(HttpServletRequest request) {
        ServletRequestAttributes attributes = new ServletRequestAttributes(request);
        LocaleContextHolder.setLocale(request.getLocale(), threadContextInheritable);
        RequestContextHolder.setRequestAttributes(attributes, threadContextInheritable);

        getLogger().debug("Bound request context to thread: {}", request);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.context.request.ServletRequestAttributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.