用Dash映射Post参数到Spring控制器中的模型
我有以下属性,我需要映射到Spring中的post参数。 我可以使用哪个属性? 它接受application / x-www-form-urlencoded用于基于字符串的有效负载,用于二进制有效负载的multipart / form-data。 其他属性映射正常,没有下划线。
String deliveryAttemptId;
映射到post参数
DELIVERY-ATTEMPT-ID
调节器
@Controller @RequestMapping("/notifications") public class NotificationController { @RequestMapping(method = RequestMethod.POST) @ResponseBody public void grade(EventNotificationRequest request, HttpServletResponse response) throws Exception { }
模型
public class EventNotificationRequest { String deliveryAttemptId;
我刚刚为Spring限制做了一个工作。 这也解决了参数的区分大小写问题。 对不起,我已经习惯了.NET以及绑定的容易程度,因此遇到这些Spring问题令人沮丧。
HttpServletRequest参数为lowecase
@RequestMapping(method = RequestMethod.POST, value = "/grade") @ResponseBody public void grade(HttpServletRequest request, HttpServletResponse response) throws Exception { EventNotificationRequest notificationRequest = new LearningStudioEventNotificationRequest(); notificationRequest.setDeliveryAttemptId(getCaseInsensitiveParameter(request, "DELIVERY-ATTEMPT-ID"));