Spring MVC -> JSON response

前端 未结 5 1810
太阳男子
太阳男子 2020-12-05 08:51

I hava a JAVA EE backend and I am using Spring MVC. I have a AJAX call like this:

function getAllProjects() {
        $.getJSON(\"project/getall\", function(         


        
5条回答
  •  广开言路
    2020-12-05 09:05

    You need to:

    • Add Jackson JSON Mapper to the classpath
    • Add to your config
    • Return Map

    For more complex cases when you need to configure mapping process for each handler method you may use MappingJacksonJsonView instead of @ResponseBody, as Stepen C suggested.

提交回复
热议问题