List of usage examples for org.springframework.web.util WebUtils FORWARD_REQUEST_URI_ATTRIBUTE
String FORWARD_REQUEST_URI_ATTRIBUTE
To view the source code for org.springframework.web.util WebUtils FORWARD_REQUEST_URI_ATTRIBUTE.
Click Source Link
From source file:com.asual.summer.core.util.RequestUtils.java
public static String getRequestUri() { String requestUri = (String) getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE); if (requestUri != null) { return requestUri; }/* w w w .ja v a 2 s .c om*/ return getRequest().getRequestURI(); }
From source file:org.parancoe.web.tag.BaseTagTest.java
@Before public void setupRequestParams() { request.setContextPath("/testctx"); request.setRequestURI("/testctx/test/request/uri"); request.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/testctx/test/forward/request/uri"); request.setQueryString("p1=v1&p2=v2&p3=v3"); }
From source file:com.asual.summer.core.util.RequestUtils.java
public static String getQueryString() { String requestURI = (String) getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE); if (requestURI != null) { return (String) getAttribute(WebUtils.FORWARD_QUERY_STRING_ATTRIBUTE); }// w w w .j a va 2s.co m return getRequest().getQueryString(); }
From source file:org.parancoe.web.test.TagTest.java
/** * Reset the request and the response, maintaining the same session. Useful, for example, to * call a post after calling the get of the form. *//*from w w w . ja va 2s. com*/ protected void resetRequestAndResponse() { HttpSession httpSession = null; // preparing the multipart request if (mpReq != null) { httpSession = mpReq.getSession(); } mpReq = new MockMultipartHttpServletRequest(); mpReq.setSession(httpSession); mpReq.setMethod("GET"); // preparing the normal request if (req != null) { httpSession = req.getSession(); } req = new MockHttpServletRequest(); req.setSession(httpSession); req.setMethod("GET"); req.setContextPath("/testctx"); req.setRequestURI("/testctx/test/request/uri"); req.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/testctx/test/forward/request/uri"); req.setQueryString("p1=v1&p2=v2&p3=v3"); res = new MockHttpServletResponse(); pc = new MockPageContext(((WebApplicationContext) this.getApplicationContext()).getServletContext(), req, res); rc = new JspAwareRequestContext(pc); pc.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, rc); }
From source file:net.paoding.rose.web.RequestPath.java
public RequestPath(HttpServletRequest request) { // method//from w w w . ja v a 2s.c o m setMethod(parseMethod(request)); // ctxpath setCtxpath(request.getContextPath()); String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath // dispather, uri, ctxpath String uri; if (WebUtils.isIncludeRequest(request)) { setDispatcher(Dispatcher.INCLUDE); uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)); setRosePath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE)); } else { uri = request.getRequestURI(); this.setRosePath(request.getServletPath()); if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) { this.setDispatcher(Dispatcher.REQUEST); } else { this.setDispatcher(Dispatcher.FORWARD); } } if (uri.startsWith("http://") || uri.startsWith("https://")) { int start = uri.indexOf('/', 9); if (start == -1) { uri = ""; } else { uri = uri.substring(start); } } if (uri.indexOf('%') != -1) { try { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { encoding = "UTF-8"; } uri = URLDecoder.decode(uri, encoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } this.setUri(uri); // requestPathctxpathincludeinvocationCtxpath if (getCtxpath().length() <= 1) { setRosePath(getUri()); } else { setRosePath( getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length())); } }
From source file:com.trenako.web.test.AbstractSpringTagsTest.java
@Before public void setup() throws Exception { mockServletContext = new MockServletContext(); // mocking the spring web application context mockWebApplicationContext = mock(WebApplicationContext.class); when(mockWebApplicationContext.getServletContext()).thenReturn(mockServletContext); when(mockWebApplicationContext.getAutowireCapableBeanFactory()) .thenReturn(mock(AutowireCapableBeanFactory.class)); mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, mockWebApplicationContext);// w w w . ja v a 2 s . c om // mocking the servlet request mockRequest = new MockHttpServletRequest(); mockRequest.setContextPath("/trenako-web"); mockRequest.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/trenako-web"); mockPageContext = new MockPageContext(mockServletContext, mockRequest); // mocking the message source to always return the default value mockMessageSource = mock(MessageSource.class); when(mockMessageSource.getMessage(anyString(), any(Object[].class), anyString(), any(Locale.class))) .thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return (String) args[2]; } }); // give the tag under test the chance to setup itself setupTag(mockPageContext, mockMessageSource); }
From source file:com.sinosoft.one.mvc.web.RequestPath.java
public RequestPath(HttpServletRequest request) { // method/* w ww. j a v a 2s. c o m*/ setMethod(parseMethod(request)); // ctxpath setCtxpath(request.getContextPath()); String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath // dispather, uri, ctxpath String uri; if (WebUtils.isIncludeRequest(request)) { setDispatcher(Dispatcher.INCLUDE); uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)); setMvcPath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE)); } else { if (request.getAttribute(MvcConstants.WINDOW_REQUEST_URI) != null) { uri = (String) request.getAttribute(MvcConstants.WINDOW_REQUEST_URI); request.removeAttribute(MvcConstants.WINDOW_REQUEST_URI); request.setAttribute(MvcConstants.IS_WINDOW_REQUEST, "1"); } else { uri = request.getRequestURI(); request.removeAttribute(MvcConstants.IS_WINDOW_REQUEST); } this.setMvcPath(request.getServletPath()); if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) { this.setDispatcher(Dispatcher.REQUEST); } else { this.setDispatcher(Dispatcher.FORWARD); } } if (uri.startsWith("http://") || uri.startsWith("https://")) { int start = uri.indexOf('/', 9); if (start == -1) { uri = ""; } else { uri = uri.substring(start); } } if (uri.indexOf('%') != -1) { try { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { encoding = "UTF-8"; } uri = URLDecoder.decode(uri, encoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } this.setUri(uri); // requestPathctxpathincludeinvocationCtxpath if (getCtxpath().length() <= 1) { setMvcPath(getUri()); } else { setMvcPath(getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length())); } }
From source file:org.springframework.web.util.UrlPathHelper.java
/** * Return the request URI for the given request. If this is a forwarded request, * correctly resolves to the request URI of the original request. *//*from w ww. j av a 2 s . c o m*/ public String getOriginatingRequestUri(HttpServletRequest request) { String uri = (String) request.getAttribute(WEBSPHERE_URI_ATTRIBUTE); if (uri == null) { uri = (String) request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE); if (uri == null) { uri = request.getRequestURI(); } } return decodeAndCleanUriString(request, uri); }
From source file:org.springframework.web.util.UrlPathHelper.java
/** * Return the query string part of the given request's URL. If this is a forwarded request, * correctly resolves to the query string of the original request. * @param request current HTTP request// w ww . ja v a2s. c o m * @return the query string */ public String getOriginatingQueryString(HttpServletRequest request) { if ((request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) != null) || (request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null)) { return (String) request.getAttribute(WebUtils.FORWARD_QUERY_STRING_ATTRIBUTE); } else { return request.getQueryString(); } }