我具有以下方法签名的控制器
@PostMapping
public String doUpdate(
@PathVariable("fooId") Long ID,
@ModelAttribute Item form,
Model model)
控制器的@RequestMapping
为>
@RequestMapping("/foo/{fooId}/Items/{itemId}/type/{type}/update")
我正在尝试通过
@ModelAttribute Item
和mockMvc
将flashAttr()
传递给控制器,如下所示
String url = String.format("/foo/%s/Items/%s/type/%s/update", fooId, itemId, type); mockMvc.perform(post(url)).flashAttr("form", updateContact))
不是用
form
中的数据填充flashAttr
,而是用fooId
,itemId
和type
填充
我有一个控制器,以下方法签名@PostMapping公共字符串doUpdate(@PathVariable(“ fooId”)长ID,@ModelAttribute项目形式,模型模型)@ ...
控制器签名中的@ModelAttibute
缺少name
属性,因此控制器自动从URL中提取参数并将其提取到@ModelAttibute
中