Answer by Wolfgang for What's the best way to get the current URL in Spring MVC?
System.out.println(((HttpServletRequest)request).getRequestURI());I used it. hope it's useful.
View ArticleAnswer by Sahil Chhabra for What's the best way to get the current URL in...
If you need the URL till hostname and not the path use Apache's Common Lib StringUtil, and from URL extract the substring till third indexOf /.public static String getURL(HttpServletRequest request){...
View ArticleAnswer by Mathias Dpunkt for What's the best way to get the current URL in...
You can also add a UriComponentsBuilder to the method signature of your controller method. Spring will inject an instance of the builder created from the current request.@GetMappingpublic...
View ArticleAnswer by Koraktor for What's the best way to get the current URL in Spring MVC?
Instead of using RequestContextHolder directly, you can also use ServletUriComponentsBuilder and its static...
View ArticleAnswer by Reed Grey for What's the best way to get the current URL in Spring...
Java's URI Class can help you out of this:public static String getCurrentUrl(HttpServletRequest request){ URL url = new URL(request.getRequestURL().toString()); String host = url.getHost(); String...
View ArticleAnswer by andy for What's the best way to get the current URL in Spring MVC?
in jsp file:request.getAttribute("javax.servlet.forward.request_uri")
View ArticleAnswer by Daff for What's the best way to get the current URL in Spring MVC?
Well there are two methods to access this data easier, but the interface doesn't offer the possibility to get the whole URL with one call. You have to build it manually:public static String...
View ArticleWhat's the best way to get the current URL in Spring MVC?
I'd like to create URLs based on the URL used by the client for the active request. Is there anything smarter than taking the current HttpServletRequest object and it's getParameter...() methods to...
View Article