Not being a Java practitioner, I recently came to learn about the JAX-RS specification and Apache CXF framework. While still wrapping my head around all these things, I also read the this question on SO.

Since MVC is a design pattern while JAX-RS is a specification, I was confused about the comparison. Granted my nascent understanding of JAX-RS, what makes it more suitable for implementing a RESTful API than say a framework that uses the MVC pattern?

N.B. I have a C and Python background.

2 Answers 2


I don't think that one could say whether any specific pattern is "optimal" for something as broad as RESTful service development. Whether that pattern is optimal depends on your business needs, design, and whether it solves a problem for you.

That said, the MVC concept can be very useful in REST development. The mindset of separating your business logic (models, controllers) away from the HTTP protocol details (view) can keep your code more flexible/reusable. It would allow you to add other protocols on top of your service more easily. For example, you could support SOAP, REST, and a custom binary socket protocol as your "views" which all use the same core logic.

As far as comparing frameworks (JAX-RS, Apache CXF, other MVC frameworks), that's more of an issue of finding one that meets your needs. You'd have to consider factors like maturity, how familiar your developers are with it, community, etc. It's important to not conflate frameworks and patterns (even though many frameworks define themselves on an implementation of a pattern).

  • The SO post seemed to be implying that JAX-RS has better support for building RESTful services than Spring MVC. Does the former make it easier to support multiple protocols and serialization formats? If Spring does not have the same level of support, that's not necessarily a knock on MVC, right?
    – Salman Haq
    Apr 18, 2013 at 2:58
  • I haven't actually used JAX-RS, so I can't really compare. I have some experience with building Spring-based REST services (though I'm not sure I'd say our pattern is MVC exactly) and can say that it seems easy enough to support multiple protocols and formats (JSON and XML are easy). But you are totally correct in that if Spring's MVC pattern isn't useful, that doesn't mean MVC is bad in general -- an implementation of a pattern != the pattern itself.
    – Allan
    Apr 18, 2013 at 23:15

It seems that people are using patterns that work for one type of scenario for everything.
MVC is totally unsuitable for REST.

REST relies on a stateless client-server communications protocol.

REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC, COM or SOAP to connect between machines, All calls are messages and there are no objects. Simple HTTP is mostly used to make calls between machines.

The World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.