The major differences between MVC 1.0 and JAX-RS are:
- An MVC controller is a JAX-RS resource annotated with
the type/method @Controller annotation (javax.mvc.annotation.Controller).
- The @Controller can be used at type or method level. This
is useful if you have a JAX-RS resource with a subset of methods that are
actually MVC controllers. This is a hybrid class acting as a JAX-RS resource
and as an MVC controller.
- MVC classes must be CDI-managed beans only (not JAX-RS
native classes, EJBs, managed beans etc). This restrictions is true for hybrid
classes also. Such classes must be CDI-managed beans.
- A String returned by an MVC controller is interpreted as
a view path rather than text content (e.g. pointing a JSP page). So, pay
attention to this aspect, because JAX-RS resource may return content text,
while MVC controllers don't.
- The default media type for a response is assumed to be
text/html,
but otherwise can be declared using @Produces just like in JAX-RS.
- A MVC controller that returns void must be decorated with
type/method @View
annotation to indicate the view to display.
- We can encapsulates a view path as well as additional
information related to its processing via the javax.mvc.Viewable class.
- The method toString() is called on other Java types and the
result interpreted as a view path.
- An MVC controller that returns a non-void type may
also be decorated with @View. In this case, the @View point the default view for
the controller. The default view will be used ONLY if you return null from your
non-void
controller.