Spring 3.0 making JSON response using jackson message converter

后端 未结 8 2020
迷失自我
迷失自我 2020-12-01 05:20

i configure my messageconverter as Jackson\'s then

class Foo{int x; int y}

and in controller

@ResponseBody
public Foo metho         


        
8条回答
  •  执念已碎
    2020-12-01 06:11

    The MessageConverter interface http://static.springsource.org/spring/docs/3.0.x/javadoc-api/ defines a getSupportedMediaTypes() method, which in case of the MappingJacksonMessageCoverter returns application/json

    public MappingJacksonHttpMessageConverter() {
        super(new MediaType("application", "json", DEFAULT_CHARSET));
    }
    

    I assume a Accept: application/json request header is missing.

提交回复
热议问题