为什么@GetMapping 方法 return 在发送响应时请求参数?
Why does @GetMapping method return request param while sending response?
我将请求参数作为 POJO 获取,但在方法中什么都不做,但在 jsp 中显示了我从 request.Why 中获取的参数,方法 return 是我的对象吗?
此外,当我使用原始类型或字符串时,它不会 return 对象并且完美地工作
控制器
@GetMapping("/ULD_details")
public String ULD_detailGet(ActionError ID){
return "ULD_detail";
JSP
<tr>
<td >ULD id</td>
<td>${actionError.ID}</td>
</tr>
Link
http://localhost:8080/UCM-controller/ULD_details?ID=1145
它不return你的对象。它 return 是字符串 "ULD_detail",这是要执行的视图的名称。
执行此视图,并在请求属性(即模型中)中找到一个 actionError
bean,因为 Spring documentation about handler methods arguments 表示:
Any other argument
If a method argument is not matched to any of the above, by default it is resolved as an @RequestParam if it is a simple type, as determined by BeanUtils#isSimpleProperty, or as an @ModelAttribute otherwise.
documentation of ModelAttribute 表示:
The default model attribute name is inferred from the declared attribute type (i.e. the method parameter type or method return type), based on the non-qualified class name: e.g. "orderAddress" for class "mypackage.OrderAddress"
我将请求参数作为 POJO 获取,但在方法中什么都不做,但在 jsp 中显示了我从 request.Why 中获取的参数,方法 return 是我的对象吗? 此外,当我使用原始类型或字符串时,它不会 return 对象并且完美地工作
控制器
@GetMapping("/ULD_details")
public String ULD_detailGet(ActionError ID){
return "ULD_detail";
JSP
<tr>
<td >ULD id</td>
<td>${actionError.ID}</td>
</tr>
Link
http://localhost:8080/UCM-controller/ULD_details?ID=1145
它不return你的对象。它 return 是字符串 "ULD_detail",这是要执行的视图的名称。
执行此视图,并在请求属性(即模型中)中找到一个 actionError
bean,因为 Spring documentation about handler methods arguments 表示:
Any other argument
If a method argument is not matched to any of the above, by default it is resolved as an @RequestParam if it is a simple type, as determined by BeanUtils#isSimpleProperty, or as an @ModelAttribute otherwise.
documentation of ModelAttribute 表示:
The default model attribute name is inferred from the declared attribute type (i.e. the method parameter type or method return type), based on the non-qualified class name: e.g. "orderAddress" for class "mypackage.OrderAddress"