users@jersey.java.net

Re: [Jersey] Jersey MessageBodyWriter for Spring ModelAndView

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 21 Aug 2009 11:21:49 +0200

Hi,

On Aug 21, 2009, at 10:39 AM, Mahdi Majidi wrote:

> Dear Sir/Ma'am
> would you please send me a reference
> for implemeting a MessageBodyWriter to return
> ModelAndView in jersey methods?
>

What is a ModelAndView? is that your own Java type?

See the entity provider sample for how to develop a MessageBodyWriter:

   http://download.java.net/maven/2/com/sun/jersey/samples/entity-provider/1.1.1-ea/entity-provider-1.1.1-ea-project.zip


Jersey has support for an MVC pattern. See the bookstore sample:

    http://download.java.net/maven/2/com/sun/jersey/samples/bookstore/1.1.1-ea/bookstore-1.1.1-ea-project.zip

One can return an instance of Viewable that encapsulates a reference
to a template and a model. By Default Jersey supports JSPs for Web
apps, there is also support for Lift templates in the scala lift
contrib module. I suspect what you mean by ModelAndView is something
similar to Jersey's Viewable [1] (the processing of which is performed
in a MessageBodyWriter).



> is jersey is a reference implementation or is the
> preferred production library to use instead of other
> libraries (resteasy).
>

Jersey is the RI *and* a production quality implementation.

Paul.

[1] https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/view/Viewable.html