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 :)

0

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.