Welcome file not working with html file in spring

前端 未结 6 1200
难免孤独
难免孤独 2020-12-19 10:09

I have given my welcome file in web.xml But when running the application, it is showing 404 error on http://172.16.2.16:8080/sampletest/

It is a spring

6条回答
  •  忘掉有多难
    2020-12-19 10:23

    At the startup by default all incoming requests are mapping to '/' pattern as you write in the web.xml:

    
        dispatcher
        /
    
    

    update:

    1. Try to map a Controller method for the default view:

      @RequestMapping(value = "/", method = GET)
      public String welcome() {
          return "index";
      }
      
    2. Add viewresolver to dispather-servlet.xml:

      
      
    3. Remove welcome file from the web.xml as automatically spring will search for index page by default:

      
          index.jsp
      
      

提交回复
热议问题