marianciu
marianciu

Reputation: 557

Spring MVC - get address from request

This is my case, set by step:

  1. Run below page under address:

localhost:8080/user/data/expenses

  1. On this page click link

localhost:8080/user/data/change_button/9_2015

  1. Now my controller is started:

Screenshot

My question: How can I get information from what side was call my controller. I need exactly this information which is strong below:

localhost:8080 /user/data/expenses

M-Z

Upvotes: 0

Views: 553

Answers (2)

Bnrdo
Bnrdo

Reputation: 5474

Infact there is way to get the referer of the request as it is part of the HTTP header. Just inject HttpServletRequest to the mapped method then get the header named "referer".

request.getHeader("referer");

Upvotes: 1

nfechner
nfechner

Reputation: 17525

You need to inject the HttpServletRequest and then use getRequestURI() to get the data. Read the javadoc for @RequestMapping.

Upvotes: 0

Related Questions