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.
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.
In SpringMVC you can specify values from the query string be parsed and passed in as method parameters with the @RequestParam annotation.
public ModelAndView getPage(
    @RequestParam(value="page", required=false) String page, 
    @RequestParam(value="gotoUrl", required = false) String gotoUrl) {
}
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");
}
Get the QueryString in Spring MVC Controller
This is Liferay portal specific solution, and it works.
Query String Example: ?reportTypeId=1&reportSeqNo=391 
In order to get the value of reportSeqNo in Liferay Portal, we need to get the Original Servlet Request.
String reportSeq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest)).getParameter("reportSeqNo");