SpringMVC and static resources

后端 未结 5 1346
野的像风
野的像风 2020-12-31 14:55

Im new in java and spring. I\'m trying to make hello world app and don\'t get what i\'m doing wrong.

here is my directory structure:

test_app
-pom.xm         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 15:52

    Just add both these lines to your dispatcher-servlet.xml

    
    
    

    Here is what the documentation for default-servlet-handler says:

    Configures a handler for serving static resources by forwarding to the Servlet container's default Servlet. Use of this handler allows using a "/" mapping with the DispatcherServlet while still utilizing the Servlet container to serve static resources. This handler will forward all requests to the default Servlet. Therefore it is important that it remains last in the order of all other URL HandlerMappings. That will be the case if you use the "annotation-driven" element or alternatively if you are setting up your customized HandlerMapping instance be sure to set its "order" property to a value lower than that of the DefaultServletHttpRequestHandler, which is Integer.MAX_VALUE.

提交回复
热议问题