我有一个在本地运行的spring webapp。它工作得非常好,并且可以将Flash属性完美地传递到另一个控制器上。
当我将其置于openshift上时,使用https路由时,flash属性功能将停止一起工作。但是,如果我使用http路由,它仍然可以正常工作。
这是我的重定向传递方法,它在路径中输入一个id,执行一些逻辑并通过someVariable重定向到/ foo端点。
@GetMapping("/foo/{someId}")
public ModelAndView redirectFoo(@RequestHeader HttpHeaders headers, @PathVariable(value = "someId") String someId, RedirectAttributes attributes) {
//..some logic
attributes.addFlashAttribute("someVariable", someVariable);
return new ModelAndView("redirect:/foo");
}
redirectFoo重定向到/ foo并通过flash属性将someVariable传递到/ foo
@GetMapping("/foo")
public ModelAndView get(@RequestHeader HttpHeaders headers, @ModelAttribute("someVariable") String someVariable) {
//...some logic with someVariable...
return new ModelAndView("foo");
}
这一切在本地都可以正常工作。但是当我使用openshift时,它就无法正常工作。
* EDIT:这似乎不是openshift问题,但更是一个https问题。如果我使用http路由,则flash属性可以正常工作。如果我使用https路由,则不会。
答案 0 :(得分:0)
正如Graham在评论中所说,这是我的应用重定向到http
而不是https
的问题。为了解决这个问题,我只需要将重定向方法更改为
@GetMapping("/foo/{someId}")
public RedirectView redirectFoo(@RequestHeader HttpHeaders headers, @PathVariable(value = "someId") String someId, RedirectAttributes attributes) {
//..some logic
attributes.addFlashAttribute("someVariable", someVariable);
RedirectView redirectView = new RedirectView("/foo");
redirectView.setHttp10Compatible(false);
return redirectView;
}