3

I want to remove the parameter from url which is coming from HeaderInterceptor.java in postHandle method when I load the get method after redirect from post method.

What is written in my HeaderInterceptor.java file is

modelAndView.addObject("roleId", stu.getRoleId());

So, when I redirect from post method to get , the url which come is: http://localhost:8080/System/StudentList.htm?roleId=23

So, here I want to remove is ?roleId=23.

Following is the code written in POST method:

String referer = request.getHeader("referer"); return "redirect:"+referer;

But I m not able to see any parameter in referer string.

The code I tried in POST method is : RedirectView redirectview = new RedirectView("?"); redirectview.setExposeModelAttributes(false);

but it is still showing the same url with parameter.

Any help would be appreciated. Thanks :)

Rucha
  • 139
  • 1
  • 8

1 Answers1

0

You can manually remove the URL parameters by calling something like String newURL = url.substring(0, url.indexOf("?"));

Wai Yan
  • 582
  • 9
  • 22
  • 1
    When I try to trace the URL in get method, I dont get any like `?roleId=23` `String url = request.getServletPath();` So how can I remove it manually by using substring operation – Rucha Jan 29 '16 at 07:13