[英]Map Post Parameter With Dash to Model In Spring Controller
I have the following property that I need mapped to a post parameter in Spring. 我需要将以下属性映射到Spring中的post参数。 Is there an attribute I can use?
有可以使用的属性吗? It accepts application/x-www-form-urlencoded for string-based payloads, multipart/form-data for binary payloads.
对于基于字符串的有效负载,它接受application / x-www-form-urlencoded;对于二进制有效负载,它接受multipart / form-data。 Other properties are mapping fine without underscores.
其他属性映射良好,没有下划线。
String deliveryAttemptId;
mapped to the post parameter 映射到post参数
DELIVERY-ATTEMPT-ID
Controller 控制者
@Controller
@RequestMapping("/notifications")
public class NotificationController {
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public void grade(EventNotificationRequest request, HttpServletResponse response) throws Exception {
}
Model 模型
public class EventNotificationRequest {
String deliveryAttemptId;
I just made a work around for this Spring limitation. 我刚刚针对此春季限制进行了解决。 This also fixes case sensitivity issues with parameters.
这也解决了参数区分大小写的问题。 Sorry I am used to .NET and how easy binding is so it's frustrating to run into these Spring issues.
抱歉,我已经习惯了.NET以及绑定有多么容易,所以遇到这些Spring问题令人沮丧。
HttpServletRequest parameter lowecase 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"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.