views:

82

answers:

1

If I have a web application that also services requests for iphone/android applications, what is the best way to go about designing the application?

i am using spring mvc.

Would it be possible (or advisable) to use the same controller action to service both web and mobile requests, or would I have to duplicate things with another set of controllers?

A: 

You certainly can use SpringMVC's REST feautures and content negotiation. Or you can write an interceptor for your controllers that can analyze request type, or use any other information that can be obtained from HTTP Request Headers, and use appropriate view (JacksonJsonView, XmlMarshallingView or JstlView depending on the requester type)

As another approach you can use some JAX-RS implementation near your spring mvc to make your services. here's a nice article on integrating spring mvc and resteasy (jboss's jax-rs impl) - http://java.dzone.com/articles/resteasy-spring

bob