尝试使用window.location.href访问端点时请求正文丢失

时间:2015-12-15 10:07:24

标签: javascript jquery ajax spring-mvc

大家好我有错误状态404基本上我试图进入另一个端点但收到错误代码:

There was an unexpected error (type=Bad Request, status=400).
Required request body content is missing: org.springframework.web.method.HandlerMethod$HandlerMethodParameter@2c553a08

$.ajax({
            type: 'post',
            url: 'guest/search',

            data: JSON.stringify(formData),
            contentType: 'application/json',
            success: function(dataRecieved){
                var dataRecieved= $.trim(dataRecieved);
                //console.log(dataRecieved);
                if(dataRecieved === 'true'){
                    $("#statusPlaceholder").html("Great rooms are available");
                    window.location.href="/guestReservation";
                }else{
                    $("#statusPlaceholder").html("Sorry. Rooms are not available. Please try again").show().fadeOut(3000).css("color","red");
                }
            }

        });

Spring mapping:

 @RequestMapping(value = "/guestReservation", method = RequestMethod.GET)
    public String createGuest(@RequestBody Guest guest){
        // return new ResponseEntity<>(guestservice.create(gst), HttpStatus.OK);
        return "guestReservation";
    }

我的问题是如何在window.location.href中添加请求主体

0 个答案:

没有答案