开发者

Can I create RESTFUL Web services in Spring 3.0 without MVC

开发者 https://www.devze.com 2023-04-03 23:32 出处:网络
Currently building a \"Business Layer\", that serves up JSON to a PHP application. Considering using Spring with growth of the application in mind.

Currently building a "Business Layer", that serves up JSON to a PHP application. Considering using Spring with growth of the application in mind.

All my research so far leads me to believe that restful web services are only possible in an MVC context. Since my 开发者_JAVA技巧front end (display tier) is not Java MVC does not make sense.

Am I missing anything or this a limitation of Spring WS ? If thats the case then what are the other possible alternatives ? Jersey/Restlet for JAX-RS ?


There's no reason you can't use Spring MVC for your REST services. It would work just as well as JAX-RS.

As long as you use mvc:annotation-driven and Jackson is on the classpath then all you should need to do is use @ResponseBody on your controller methods and the return type will be converted to JSON per Spring's standard HTTP Message Conversion functionality.

Also check out this video at around 37:00: Mastering Spring MVC.

0

精彩评论

暂无评论...
验证码 换一张
取 消