Hi there,I'm new in here.. This is my very first post and i hope that someone could help me.
I'm developing a web app with spring which use ContentNegotiantingViewResolver to delegate the correct response in html or Json.
If I ask for the json, response is a correct json string. But if i ask for a view which is resolved by the internalResourceViewController (Url:manifestazioni.list), I've got a servletException which complain about
Diving deeper in resolveViewName (in org.springframework.web.servlet.ContentNegotiation ViewResolver) i see that the List<MediaType> requestedMediaTypes contains only [application/octect-stream]. So the next method getBestView could not find any view resolver for the view name.Code:"Could not resolve view with name 'organizzazioni' in servlet with name 'subscriptionmanager'"
I've a page called manifestazioni.jsp inside /WEB-INF/jsp
Following there are web.xml, subscriptionmanager-servlet.xml a a little part of the controller. I'm using spring-webmvc 3.0.6 inside an appengine app
the web.xml
the servlet xmlCode:<display-name>SubscriptionManager</display-name> <welcome-file-list> <welcome-file>redirect.jsp</welcome-file> </welcome-file-list> <servlet> <display-name>SubscriptionManager</display-name> <servlet-name>subscriptionmanager</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>subscriptionmanager</servlet-name> <url-pattern>*.html</url-pattern> <url-pattern>*.save</url-pattern> <url-pattern>*.list</url-pattern> <url-pattern>*.show</url-pattern> <url-pattern>*.choose</url-pattern> <url-pattern>*.confirm</url-pattern> </servlet-mapping>
and the controllerCode:<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="json" value="application/json"/> <entry key="html" value="text/html"/> </map> </property> <property name="viewResolvers" > <list> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" > <property name="order" value="0" /> </bean> </list> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"> </bean> </list> </property> </bean>
Code:@RequestMapping(value="/organizzazioni.list",method=RequestMethod.GET) public ModelAndView listOrganizzazioni() { ModelAndView mav= new ModelAndView(); mav.setViewName("organizzazioni"); mav.addObject("organizzazioni",service.getAllOrganizzazioni()); return mav; } @RequestMapping(value="/organizzazioni.list",headers = { "Accept=application/json" }) @ResponseBody public List<Organizzazione> listOrganizzazioniAsJson() { return service.getAllOrganizzazioni(); }


Reply With Quote
