How can I get the referer URL in Spring MVC Controller?
相关问题
- org.apache.commons.fileupload.disk.DiskFileItem is
- @DateTimeFormat in Spring produces off-by-one day
- Java-Reflection - find the Arguments and the annot
- Json string from LocalDateTime(java 8) in Spring M
-
type not resolved
相关文章
- spring-mvc a标签带参怎样向controller发送请求。路径格式?
- Java spring framework - how to set content type?
- Java/Spring MVC: provide request context to child
- Spring 5 Web Reactive - Hot Publishing - How to us
- Spring MVC project not able to publish and run… Me
- Intercept @RequestHeader exception for missing hea
- “400 Bad Request” response for AJAX request
- Why form submit opens new window/tab?
It's available as HTTP request header with the name
referer
(yes, with the misspelling which should have beenreferrer
).Here the
request
is theHttpServletRequest
which is available in Spring beans in several ways, among others by an@AutoWired
.Please keep in mind that this is a client-controlled value which can easily be spoofed/omitted by the client.
In Spring MVC 3 you can get it from request, as @BalusC already said:
but there also exists special annotation @RequestHeader which allow to simplify your code to