AngularJS发布数据显示“客户端发送的请求在语法上不正确”

菲尼

角度发布请求

                $http({
                      method: 'POST',
                      url: '/Eatery/save',
                      contentType:'application/json',
                      dataType:'json',
                      data:JSON.stringify(resvnCtrl.user)
                });

预约模式

@Entity
@Table(name="reservations")
public class Reservation implements Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = -2657656545798031761L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int id;
    private String cnf;
    private String name;
    private String email;
    private String phone;

    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    private LocalDateTime time;
    private int seats;
    private String note;

    public Reservation() { }

    public Reservation(String cnf, String name, String email, String phone,
            LocalDateTime time, int seats, String note) {
        this.cnf = cnf;
        this.name = name;
        this.email = email;
        this.phone = phone;
        this.time = time;
        this.seats = seats;
        this.note = note;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCnf() {
        return cnf;
    }

    public void setCnf(String cnf) {
        this.cnf = cnf;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @JsonSerialize(using=CustomDateSerializer.class)
    public LocalDateTime getTime() {
        return time;
    }

    public void setTime(LocalDateTime time) {
        this.time = time;
    }

    public int getSeats() {
        return seats;
    }

    public void setSeats(int seats) {
        this.seats = seats;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

}

弹簧控制器

@RequestMapping(value="/save",method=RequestMethod.POST,consumes=MediaType.APPLICATION_JSON_VALUE,produces=MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public int save(@RequestBody Reservation reservation) {
        System.out.println(reservation.getTime());
        return reservationRepo.save(reservation);   
    }

我有一个角度发布请求,该请求发送JSON数据,还有一个处理该请求的弹簧控制器。当我尝试此操作时,出现错误客户端发送的请求在语法上不正确前端的数据来自表单。我正在使用Bootstrap日期选择器进行日期选择。有人可以发现我的错误吗

bl0u0l

无需对数据对象进行字符串化。

            $http({
                  method: 'POST',
                  url: '/Eatery/save',
                  contentType:'application/json',
                  dataType:'json',
                  data:resvnCtrl.user
            });

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

客户端发送的请求在语法上不正确,而使用AngularJS通过其余部分调用WebService时

客户端发送的请求在语法上不正确-JSON POST正文中的类型复杂

Android错误:MultipartEntity,客户端发送的请求在语法上不正确

Spring形式:客户端发送的请求在语法上不正确()

春季HTTP错误400客户端发送的请求在语法上不正确

春季:客户端发送的请求在语法上不正确()

“客户端发送的请求在语法上是不正确的。” -内容类型错误

客户端发送的请求在语法上不正确。在@ManyToOne关系中休眠,春季

在node.js中发送带有XML数据的POST请求:错误400,“客户端发送的请求在语法上不正确”

Skrill重定向错误“ JBWEB000120:客户端发送的请求在语法上不正确。”

DHTMLX dhtmlxForm.send()抛出HTTP状态400-“客户端发送的请求在语法上不正确。”

Spring MVC:创建新的实体记录时,客户端发送的请求在语法上不正确

Spring MVC表单-Long和String值。客户端发送的请求在语法上不正确

通过客户端发送的请求是语法不正确的Java ZonedDateTime后端

春季客户发送的请求在语法上不正确()

客户端发送的请求在语法上是错误的

'.' 附近的语法不正确 (Microsoft SQL Server 本机客户端 11.0)

TCP客户端/服务器消息发送不正确

Apollo GraphQL 客户端格式化请求不正确

Microsoft OneDrive客户端设置不正确的lastModifiedDateTime

在没有客户端请求的情况下在客户端套接字上发送数据

如何使multer正确解析与表单数据一起发送的客户端请求?

symfony WebTestCase客户端不发送发布数据

Clickhouse客户端无法在Linux屏幕上正确显示数据

如何正确地将数据解析到我的改造客户端中以执行发布请求

400客户端错误:在Django中使用python-social-auth进行Facebook身份验证的请求不正确

客户端React JS发布请求

Jekyll不正确的语法突出显示

PayPal订单第2版:请求格式不正确,语法上不正确或违反架构