When using Spring MVC for REST, how do you enable Jackson to pretty-print rendered JSON?

后端 未结 10 542
遥遥无期
遥遥无期 2020-12-04 14:25

While developing REST services using Spring MVC, I would like render JSON \'pretty printed\' in development but normal (reduced whitespace) in production.

10条回答
  •  盖世英雄少女心
    2020-12-04 14:48

    I had trouble getting the custom MappingJacksonHttpMessageConverter to work as suggested above but I was finally able to get it to work after struggling w/ the configuration. From the code stand point I did exactly what was mentioned above but I had to add the following configuration to my springapp-servlet.xml to get it to work.

    I hope this helps others who are looking to implement the same.

    
        
            
                
            
        
    
    
    
        
        
    
    

提交回复
热议问题