Jetty RESTful with multiple data formats
I am a newbie in this area, I am using embedded jetty to create web services and I have few existing methods/开发者_开发百科pojos which I need to make as RESTful API's and I want support for multiple data formats like JSON/XML etc.. can anyone suggest a good tutorial or steps/suggestions.
I am using Java (Eclipse + Maven)
Thanks in advance
I think the easiest method to build RESTful services on top of POJOs is to use JAX-RS (implemented via Jersey or Apache CXF, to give two examples). Those sorts of frameworks are then deployed (with your classes) inside a servlet container, such as Jetty.
I use CXF to serve up both XML and JSON off the same model classes (with the service interface described as an annotated interface, a nice approach). It works (provided you don't have abstract classes as arguments) and there are some reasonable docs and tutorial examples online.
精彩评论