Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在反向代理丢失flash属性后重定向spring应用程序_Spring_Redirect_Proxy - Fatal编程技术网

在反向代理丢失flash属性后重定向spring应用程序

在反向代理丢失flash属性后重定向spring应用程序,spring,redirect,proxy,Spring,Redirect,Proxy,我的应用程序在POST操作后将一些信息重定向到GET控制器,但与Apache和反向代理一起使用时会丢失这些信息。当我在中间没有反向代理的时候做这个操作,一切都很好。一些想法 @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "aCategory", method = RequestMethod.POST) public String category(@RequestParam("aCategor

我的应用程序在POST操作后将一些信息重定向到GET控制器,但与Apache和反向代理一起使用时会丢失这些信息。当我在中间没有反向代理的时候做这个操作,一切都很好。一些想法

    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @RequestMapping(value = "aCategory", method = RequestMethod.POST)
    public String category(@RequestParam("aCategoryName") String name, Model model, RedirectAttributes attr,
                        HttpServletRequest request) {

                String redirect = "redirect:" + "http://localhost:8080/aCategory";
                aService.saveACategory(name);
                attr.addFlashAttribute("aCategoryName", name);
                return redirect;
    }


    @RequestMapping(value = "aCategory", method = RequestMethod.GET, produces = "text/html")
    public String appCategory(Model model, Principal principal) {
        String name = principal.getName(); // get logged in username
        model.addAttribute("username", name);
        return "aCategory";
    }

这取决于您的群集配置和会话复制配置。因为FlashAttributes首先临时存储在会话中,然后再将其添加到模型映射以在重定向视图上显示。因此,如果您的集群没有为正确的会话复制进行良好配置,那么当请求由另一个集群提供服务时,您的FlashAttribute可能会丢失,而不是实际存储在会话中的FlashAttribute

有关更多详细信息,请参阅我的


希望这对你有帮助。干杯。

这取决于您的群集配置和会话复制配置。因为FlashAttributes首先临时存储在会话中,然后再将其添加到模型映射以在重定向视图上显示。因此,如果您的集群没有为正确的会话复制进行良好配置,那么当请求由另一个集群提供服务时,您的FlashAttribute可能会丢失,而不是实际存储在会话中的FlashAttribute

有关更多详细信息,请参阅我的

希望这对你有帮助。干杯