I am new in Java, In our application we are using RedirectView for redirecting to particular URL. My question here is there any way by which I can set Headers to this RedirectView Url. As we need to send some data at the redirected Page. I know its a silly question, I have just started studying Java :) Regards, Manish
Asked
Active
Viewed 3,450 times
2 Answers
0
springboot
RedirectView redirectView = new RedirectView("redirect:/users");
redirectView.setPropagateQueryParams(true);
return redirectView;

sagar226
- 5
- 1
- 6
-
Ok, But how are you going to Custom Header information in this ? – user1283878 Mar 08 '19 at 06:47
-
see this : https://stackoverflow.com/q/18534478/8747660 and custom with redirectView – sagar226 Mar 08 '19 at 06:56
0
You can set using response
. I have taken the example for file attachment.
@RequestMapping(value="",method=RequestMethod.Method)
public myMethod(HttpServletResponse response) throws IOException
{
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename);
response.setContentType("application/XXX");
}
You can set the following methods to set response Header
- void setHeader(String name, String value)
- void addDateHeader(String name, long date)
- void addHeader(String name, String value)
- void addIntHeader(String name, int value)
- String encodeRedirectURL(String url)
- String encodeURL(String url)
- void addCookie(Cookie cookie) ...

Romil Patel
- 12,879
- 7
- 47
- 76