How I can send json response from my spring controller?

前端 未结 2 956
长发绾君心
长发绾君心 2021-01-17 04:44

I\'m a newbie in the theme. How can I return JSON data from my controller, using something like that (using ResponseBody)

@RequestMapping(value = \"/ajaxtest         


        
2条回答
  •  忘掉有多难
    2021-01-17 05:31

    If you are using maven, you can include the following dependency in your pom.xml

    Jackson Mapper Version 1 which is good enough to convert your object to JSON object:

    
        org.codehaus.jackson
        jackson-mapper-asl
        1.9.13
    
    

    Or you can also go for latest Jackson version,

    
        com.fasterxml.jackson.core
        jackson-databind
        2.6.0
    
    
    
        com.fasterxml.jackson.core
        jackson-core
        2.6.0
    
    
    
        com.fasterxml.jackson.core
        jackson-annotations
        2.6.0
    
    

提交回复
热议问题