Spring Boot exception: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

I found a workaround putting a dummy dispatcherServlet-servlet.xml file under WEB-INF: <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd”> <!– Do not remove this file! –> </beans>

What does do?

The mvc:annotationDriven tag essentially sets you your Spring context to allow for dispatching requests to Controllers. The tag will configure two beans DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter. You can find more information from the spring documents: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html

Http Post with request content type form not working in Spring MVC 3

Unfortunately FormHttpMessageConverter (which is used for @RequestBody-annotated parameters when content type is application/x-www-form-urlencoded) cannot bind target classes (as @ModelAttribute can). Therefore you need @ModelAttribute instead of @RequestBody. If you don’t need to pass different content types to that method you can simply replace the annotation: @RequestMapping(method = RequestMethod.POST) public ModelAndView create(@ModelAttribute UserAccountBean account) { … … Read more

Spring MVC : read file from src/main/resources

Resource resource = new ClassPathResource(fileLocationInClasspath); InputStream resourceInputStream = resource.getInputStream(); using ClassPathResource and interface resource. But make sure you are copying the resources directory correctly (using maven), and its not missing, for example if running tests as part of test context.

Web-application context/ root application context and transaction manager setup

As explained in the documentation, every dispatcher servlet has its own application context, where you typically define controllers, view resolvers, etc., and which inherits (and can override beans) from a root application context, which typically contains data source definitions, middle tier services, etc. The ContextLoaderListener, as its documentation explains, is used to to start up … Read more