Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

java - spring: return JSON from controller as ModelAndVIew

How can I return JSON from spring controller as a view or ModelAndView? I am not interested in using @ResponseBody annotation. Is there any other way of doing this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, you can return a MappingJacksonJsonView or assign it to a ModelAndView object using mav.setView(new MappingJacksonJsonView()).

Update: In Spring 4 MappingJacksonJsonView is deprecated. You might want to upgrade to MappingJackson2JsonView


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...