0

I have a website on which I added a dropdown menu and a button. When the dropdown menu changes it calls a Requestmapping "/Filter".

The following code is underlying the Requestmapping "/Filter"

@Controller
public class FilterController
{

@RequestMapping(value = "/Filter")
public String selectmenu(@RequestParam String selectmenu, HttpServletRequest request)
{
    System.out.println(selectmenu);

    String URL = makeUrl(request);
    System.out.println(URL);

    return “ABC";
};

public static String makeUrl(HttpServletRequest request)
{
    return request.getRequestURL().toString() + "?" + request.getQueryString();
}
}

This returns the following URL: http://localhost:8080/Filter?null

I understand why this URL is returned. But the URL in the address bar is different, namely: http://localhost:8080/Name?id=1

I want to retrieve the URL in the address bar, how can this be accomplished?

Mel
  • 5,837
  • 10
  • 37
  • 42
Gerard B.
  • 43
  • 4
  • I'm sorry for posting. When I searched i couldn't find the answers. When i posted this post The third related post gave the answers. – Gerard B. Aug 25 '17 at 09:45
  • 1
    Possible duplicate of [HttpServletRequest to complete URL](https://stackoverflow.com/questions/2222238/httpservletrequest-to-complete-url) – Ruslan Akhundov Aug 25 '17 at 13:17

0 Answers0