【发布时间】:2019-11-22 03:09:32
【问题描述】:
我想使用 postman 测试我的控制器,但不知道如何使用 postman 发送模型属性。我什至不知道这是否可行。
我的控制器看起来像:
@Controller
@RequestMapping(path = "/api/v1")
public class PaymentController {
@Autowired
private CredentialsRepository credentialsRepository;
@PostMapping(path = "/charge")
public String charge(@ModelAttribute("pay-load") PayLoad payLoad, Model model) {
Credentials creds = credentialsRepository.findCredentialsById(1);
if (creds == null)
return "init_credentials";
return "charge";
}
}
模型属性
public class PayLoad {
private Integer mId;
private Integer ordId;
private Integer cardId;
private Integer cvvNo;
private String hash;
// getter & setter
}
【问题讨论】: