Get Query String Values in Spring MVC Controller

java, jsp, spring, spring-mvc

Solution

You can use the getParameter() method from the HttpServletRequest interface.

For example;

  public void getMeThoseParams(HttpServletRequest request){
    String page = request.getParameter("page");
    String goToURL = request.getParameter("gotoUrl");
}

Problem

I have a referrer URL like this: http://myUrl.com?page=thisPage&gotoUrl=https://yahoo.com?gotoPage How do I get the Values of "page" and "gotoUrl" in my Spring Controller? I want to store these values as variables, so I can reuse them later.

Original source