Issue
I was wondering if someone has already solved this. I have a SpringMVC app and we are adding support to WebKit type mobiles (iPhone and Android basically) so I was wondering someone has found an elegant way of defining specific views depending on the client that sent the request.
I know that a simple if in a Controller implementation can do the trick, but I'm looking for something more flexible/elegant (a specific ViewResolver implementation, or an interceptor maybe).
Help will be greatly appreciated... as always =)
This is a pretty old question. What you need to do is use Spring-Mobile to achieve this in a standard elegant manner
Solution
Ok I found a more specific answer. There is a problem with the solution that Bozho proposed. the fact that the ViewResolvers no longer have access to the HttpServletRequest. There is a way to access the request but its kind of dirty IMHO.
So that said, this is a very elegant and easy to implement solution. Basicly it involves a custom ViewResolver (as Bozho proposed) but it adds an handlerInterceptor that adds the User-Agent to the model so you no longer have to add it manually.
Answered By - Chepech