tag:blogger.com,1999:blog-1699950446304666715.post8575903030831312220..comments2023-06-16T12:05:47.873-04:00Comments on Gunnar Hillert's Blog: REST with Spring - ContentNegotiatingViewResolver vs. HttpMessageConverter+ResponseBody AnnotationGunnar Hillerthttp://www.blogger.com/profile/12757936011493339624noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-1699950446304666715.post-20266719378582074942012-07-06T03:53:50.425-04:002012-07-06T03:53:50.425-04:00Hi Gunnar,
I stumbled across your blog entry, whe...Hi Gunnar,<br /><br />I stumbled across your blog entry, when I searched for a solution to the problem, where I cannot have HttMessageConverter and a ViewResolver working together. But for my WebServices, I like to have a text/html view for all my WebServices.<br /><br />So I just had a look at the AnnotationMethodHandlerAdapter which is responsible for delegating the WebRequests to a suitable method and for deciding for what to do with the call's result.<br /><br />The solution is simple: You have the chance to translate your @ResponseBody to a ModelAndView by registering a custom ModelAndViewResolver with the adapter. In addition with a custom annotation (@ModelAndViewParams({@ModelAndViewParam(value = "myView", modelType = MyModelReturnedAsResponseBody.class}), It now creates a ModelAndView when certain preconditions are met, so the ViewResolver is used over the HttpMessageConverter.<br /><br />I hope that helps everyone looking for a solution to the same problem.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1699950446304666715.post-83727656548431866252011-06-08T07:17:31.518-04:002011-06-08T07:17:31.518-04:00Hi,
When i m using "InternalResourceViewResol...Hi,<br />When i m using "InternalResourceViewResolver" & "BeanNameViewResolver" in my application then "InternalResourceViewResolver" is working.<br />Plz. tell solution, how i can use mulitple view resolver in my application.<br />E-mail ID: jagdeepsinghdhiman@live.comJagdeephi, when i m using "internalresourceviewresolver" & "beannameviewresolver" in my application then "internalresourceviewresolver" is working. plz. tell solution, how i can use mulitple view resolver in my application. e-mail id: jagdeepsinghdhiman@live.comnoreply@blogger.comtag:blogger.com,1999:blog-1699950446304666715.post-24978934683410712652011-02-16T14:23:48.365-05:002011-02-16T14:23:48.365-05:00could you please post how you configured different...could you please post how you configured different view resolvers based on @ResponseBody+HttpMessageConverter<br /><br />Suport the following formats<br />1. xml<br />2. json<br />3. html<br />4. jsp<br />5. image / videoAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1699950446304666715.post-64428757332367788882011-01-26T08:55:04.201-05:002011-01-26T08:55:04.201-05:00Yes, ContentNegotiation based on the Browser-Accep...Yes, ContentNegotiation based on the Browser-Accept-Header is absolutely evil. I went into the same trap because the spring docs write about it like the holy grail...<br />Just use separate URLs (e.g. via file extension) for separate content!spgmxnoreply@blogger.comtag:blogger.com,1999:blog-1699950446304666715.post-9271327284269949972011-01-26T01:45:35.838-05:002011-01-26T01:45:35.838-05:00Gunnar,
Just for the records ;) Potential method...Gunnar, <br /><br />Just for the records ;) Potential method for adding new message converters when using <i>mvc:annotation-driven</i> can be found at one of my posts <a rel="nofollow">http://vard-lokkur.blogspot.com/2010/11/spring-mvc-pitfall-overriding-default.html</a>. I know, I wrote about WebBindingInitializer ;), but AnnotationMethodHandlerAdapter registered by <i>mvc:annotation-driven</i> tag has also getter/setter for messageConverters. <br /><br />regards<br /><br />PS: interesting article :)varð-lokkur (warlock)https://www.blogger.com/profile/08196109352954198217noreply@blogger.com