Grails fails to parse request when content type is specified during post

后端 未结 1 578
一生所求
一生所求 2021-01-28 23:47

Using wget I make two posts to the same url with xml in the body. The first works. The second has the content type specified and it does not work. Why is this an

1条回答
  •  有刺的猬
    2021-01-29 00:08

    With content type specified content will be received as part of request body instead of parsed params.

    Body can be accessed as request.XML in action. Going through the comments, we found out the usage of a older way to bindData. With Grails 2.3.*, the request payload can be directly bound to a domain object provided the body has a valid id as :

    def save(MyDomain abc){
        //use abc.name
    }
    

    If a valid id is not present in request body then domain object will be null inside the action.

    @Data binding.

    0 讨论(0)
提交回复
热议问题