Null ModelAndView returned to DispatcherServlet

后端 未结 2 1616
独厮守ぢ
独厮守ぢ 2021-01-06 05:05

I\'m trying to run my web application using Spring, Hibernate and Apache Tiles. It seems the code has no errors, but I\'m just getting a 404 page.

/var/log/tomcat7/c

相关标签:
2条回答
  • 2021-01-06 05:33

    I solved it.

    There are two contexts: root (application wide) and servlet context I defined viewResolver, tilesConfigurer, tx:annotation-driven and mvc:annotation-driven in the root context.

    Moving it to the servlet context solved the problem.

    UPDATED I've moved viewResolver, tilesConfigurer, tx:annotation-driven and mvc:annotation-driven definitions from applicationContext.xml to contextConfigLocation (dispatcher-servlet.xml)

    0 讨论(0)
  • 2021-01-06 05:40

    Try sending ModelAndView instead of String Or

    You can send map object as parameter to ModelandView method(which is already overloaded)

    @Controller 
    @RequestMapping("/") 
    public class BlogController {
        @RequestMapping("/index.html")
        public ModelAndView posts(Map<String, Object> map) {
          return new ModelAndView("/index.jsp", "status", status);
        } 
    }
    
    0 讨论(0)
提交回复
热议问题