I am facing issue in getting attributes after redirecting in external url. I am getting attributes values as null when redirecting to external url where as If I put these method in same webapp It works.
Please suggest what I am doing wrong, or if there is any way, so that I can pass attribute to redirected url and use It.
I don't want attributes to be shown as Queryparams.
sample code is as below.
//Controller in app1
@PostMapping("/redirect")
public RedirectView next(RedirectAttributes redirectAttributes, Model model, HttpServletResponse response, HttpServletRequest request) {
request.setAttribute("payment",new Payment("1","2","3"));
redirectAttributes.addAttribute("test", "test");
redirectAttributes.addFlashAttribute("message", "Successfully changed..");
redirectAttributes.addFlashAttribute("payment1",new Payment("1","2","3"));
request.setAttribute(
View.RESPONSE_STATUS_ATTRIBUTE, HttpStatus.TEMPORARY_REDIRECT);
RedirectView redirectView = new RedirectView("redirect:http://localhost:8085/redirectedPostToPost", true);
redirectView.addStaticAttribute("payment",new Payment("1","2","3"));
return redirectView;
}
//Controller of app2.
@PostMapping("/redirectedPostToPost")
public ModelAndView redirectedPostToPost(@ModelAttribute("message") String message,@ModelAttribute("payment") Payment payment,@ModelAttribute("payment1") Payment payment1, RedirectAttributes redirectAttributes,Model model, HttpServletResponse httpServletResponse, HttpServletRequest request, ModelAndView modelview) {
logger.info("in redirectedPostToPost:{} : modelview:{}", model, modelview.getModel());
Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request);
logger.info("flashmap:{}", inputFlashMap);
return new ModelAndView("about");
}
Thanking you guys in advance.