Basic Spring MVC config: PageNotFound using InternalResourceViewResolver

后端 未结 5 1776
礼貌的吻别
礼貌的吻别 2020-12-14 23:14

I\'m trying to get a first Spring 3 MVC setup running.

My app is running on tomcat, with in the server context of \"grapevine\"

For the purposes of testing,

5条回答
  •  失恋的感觉
    2020-12-15 00:02

    Solution 1: You can register your servlet at *.html and *.json (or xml, gif, png...):

    
        RestServlet
        
           org.springframework.web.servlet.DispatcherServlet
        
    
    
    
      RestServlet
      /
      *.html
      *.json
     
    

    Solution 2: If you want to keep your servlet mapped at /*, add the following to your spring.xml file:

     
    

    And this to your web.xml file:

    
      jsp
      /WEB-INF/jsp/*
     
    
    
      jsp
      org.apache.jasper.servlet.JspServlet
    
    

    The rationale is explained here: spring, web.xml. This will register an explicit handler for JSP pages with greater precedence than /*.

提交回复
热议问题