Null ModelAndView returned to DispatcherServlet

纵饮孤独 提交于 2019-11-30 22:33:29
Narendra Kumar Achari

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);
    } 
}

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!