Skip to content

JsonSelectorView not working with POST method and @RequestBody input parameter in Spring #248

@get2parag

Description

@get2parag

While running Yoga on a spring boot application using yoga-springmvc & yoga-core lib v1.06, I faced this issue where the response returned by JsonSelectorView was always coming as empty like "{}" in case of a POST method which is taking an input with @RequestBody spring annotation.
Details:-
I tried it with a very simple POJO having a @core annotation over a prepopulated spring attribute.

The API / Controller (& NOT @RestController as suggested) details were like this:-
@RequestMapping((value = "/data", method = RequestMethod.POST)
public TestDTO getData( @RequestBody DataRequestDTO dataReq)

The yoga config was done as exactly mentioned here : https://github.com/skyscreamer/yoga/wiki/Tutorial:-SpringMVC

The same method starting giving result after removing the @RequestBody annotation while taking entity as input through POST method.
I could verify the same by debugging yoga where in while rendering the jsonview the model was showing the type as input request dto instead of the out going test dto and value as empty.
Not sure like @ResponseBody-which is prohibited to be used by Yoga, @RequestBody is also messing with the view rendering or if it is a known issue.
Let me know if more info is required around the config or POJOs to reproduce this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions