jjzjj

RedirectAttributes

全部标签

java - 如何测试该方法已添加 redirectAttributes ?(通过 MockMvc)

我写了这个方法:@RequestMapping(value="/someURL",method=GET)publicStringmyMethod(RedirectAttributesredirectAttributes){redirectAttributes.addAttribute("rd","rdValue");redirectAttributes.addFlashAttribute("fa",faValue);return"redirect:/someOtherURL";}测试代码:@TestpublicvoidmyMethod()throwsException{MockHttp

java - Spring RedirectAttributes : addAttribute() vs addFlashAttribute()

到目前为止,我的理解是关于我们的Controller请求映射方法,我们可以指定RedirectAttributes参数并在请求被重定向时使用属性填充它。示例:@RequestMapping(value="/hello",method=GET)publicStringhello(RedirectAttributesredirAttr){//shouldIuseredirAttr.addAttribute()orredirAttr.addFlashAttribute()here?//...return"redirect:/somewhere";}然后重定向属性将在重定向到的目标页面上可用。

java - Spring RedirectAttributes : addAttribute() vs addFlashAttribute()

到目前为止,我的理解是关于我们的Controller请求映射方法,我们可以指定RedirectAttributes参数并在请求被重定向时使用属性填充它。示例:@RequestMapping(value="/hello",method=GET)publicStringhello(RedirectAttributesredirAttr){//shouldIuseredirAttr.addAttribute()orredirAttr.addFlashAttribute()here?//...return"redirect:/somewhere";}然后重定向属性将在重定向到的目标页面上可用。