Quantcast
Channel: What's the best way to get the current URL in Spring MVC? - Stack Overflow
Browsing all 8 articles
Browse latest View live

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 Article


Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

What'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

Browsing all 8 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>