I would know how works the configuration about Spring MVC rest services that returns JSON.
I have configurated the applicationContenxt.xml in this way:
And this is the code of my controller:Code:<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/> </list> </property> </bean> <bean id="contentNegotiatingViewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="json" value="application/json"/> </map> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/> </list> </property> </bean> <bean class="com.MyController"></bean>
I'm missing something about xml configuration or Java code? I have always error 404 while trying to invoke this resource: http://localhost:8080/fss/MyController/getValueCode:@Controller(value="MyController") public class MyController { @RequestMapping(value="/getValue", method=RequestMethod.GET) public ModelAndView getValue() { Map model = new HashMap(); model.put("asasa", "bbbbb"); model.put("cccc", "ddddd"); return new ModelAndView("jsonView",model); } }


Reply With Quote