We are using jsp's in our application, but for some specific situation we want the contents to get opened in PDF format. We are using internalviewresolver for jsp combining with tiles. Also I have read that we can BeanNameViewResolver for other views..can anyone tell me complete procedure how should I do that... I tried the same..created a class extending the abstractpdfview made entry for that in servlet.xml. also declared beannameviewresolver bean. But when I return the logical name of view from controller with MV. it gives error no view exist for that logical name...
I did entries like this: <bean id="beanNameViewResolver" class= "org.springframework.web.servlet.view.BeanNameViewResolver"/> <bean id="pdfView" class="com.tier.uiconnect.pdfView" />
As I specified in previous post we are using Internalviewresolver also for jsp view in the same servlet.xml and from controller I return 'pdfView' , now where I'm commiting mistake. also when I specified order property of the resolvers, it gave error invalid property.
Which version are you using ? In 1.2, the InternalResourceViewResolver is always the last resolver in the chain, so it doesn't have an order property. Sorry, the sample I've sent was for 2.0. You don't need to set this property with only two resolvers.
So this will do :
In your controller, how did you return the ModelAndView ? Did you set the right name "pdfView" ?
Thanks for the information, I did the same as you mentioned, I returned from my controller
return new ModelAndView("pdfView","pdfBytes",pdfBytes); where pdfBytes is byte.
But it gave error no view found for pdfView...I think it was trying to search with internalviewresolver and was trying to find a definition in tiles definition.xml where it did not found a view for pdfView.
Hey, I also met the same issue, I fixed it by setting the order of the resolver, make the beanNameViewResolver as the first choose for views. Hope this tip can help the others.
I believe we can set multiple view resolvers in spring, like BeanNameViewResolver and InternalResourceViewResolver. And I think spring will choose the second resolver only if the first one can't recognize the view name which is passed from controller.