Example usage for org.springframework.web.util UrlPathHelper getServletPath

List of usage examples for org.springframework.web.util UrlPathHelper getServletPath

Introduction

In this page you can find the example usage for org.springframework.web.util UrlPathHelper getServletPath.

Prototype

public String getServletPath(HttpServletRequest request) 

Source Link

Document

Return the servlet path for the given request, regarding an include request URL if called within a RequestDispatcher include.

Usage

From source file:org.wallride.web.support.BlogLanguageRewriteMatch.java

@Override
public boolean execute(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    UrlPathHelper urlPathHelper = new UrlPathHelper();
    String originalPath = urlPathHelper.getLookupPathForRequest(request);

    String rewritePath = originalPath.replaceAll("^/" + blogLanguage.getLanguage() + "/", "/");
    matchingUrl = rewritePath;/*from ww  w. ja  va  2  s.co  m*/
    logger.debug(originalPath + " => " + rewritePath);

    request.setAttribute(BlogLanguageMethodArgumentResolver.BLOG_LANGUAGE_ATTRIBUTE, blogLanguage);

    RequestDispatcher rd = request.getRequestDispatcher(urlPathHelper.getServletPath(request) + rewritePath);
    rd.forward(request, response);
    return true;
}