Why can't the resource be found when spring mvc sets the view suffix to html?

1. Files with suffixes jsp and html exist. When the suffix is set to jsp, access to the corresponding url can be accessed. When it is html, the access url cannot find resources. Why? I have guessed that it is because url-pattern is set to "/", but why html can"t and jsp can.

2. The related code is as follows:
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
    <servlet>
        <servlet-name>app</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:myMVC.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>app</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

myMVC.xml accessing url has no effect when suffix is set to html, but jsp can

<beans xmlns = "http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context = "http://www.springframework.org/schema/context"
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    <context:component-scan base-package = "hello" />

    <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name = "prefix" value = "/WEB-INF/pages/" />
        <property name = "suffix" value = ".html" />
    </bean>

</beans>

HelloController.java

@Controller
@RequestMapping("")
public class HelloController {

    @GetMapping("/hello")
    public String handle(Model model) {
        model.addAttribute("message", "Hello World!");
        return "index";
    }

}

3. There will be an error message org.springframework.web.servlet.DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI [/ WEB-INF/pages/index.html] in DispatcherServlet with name "app"
what is the cause of this phenomenon?


add < mvc:default-servlet-handler/ > to the configuration file of spring mvc: try it!

the default Servlet for the Web application
in the < tomcat installation directory > confweb.xml file, register a Servlet, named org.apache.catalina.servlets.DefaultServlet and set the Servlet to the default Servlet, mapping path to a forward slash (/).
any URL, that cannot find a matching < servlet-mapping > element in the web.xml file will pass its access requests to the default Servlet, that is, the default Servlet is used to handle all access requests that are not handled by other Servlet.
for example: when you access a static HTML file and image in a Tomcat server, you are actually accessing the default Servlet.
the servlet, that you now configure in web.xml with a mapping path of / this servlet becomes the default servlet. You will not be able to access the servlet provided by the original tocmat (similar to other servers), and you will not be able to handle static HTML file access.
< mvc:default-servlet-handler/ >
if the DispatcherServlet request mapping is configured to "/", Spring MVC will capture all requests of the Web container, including requests for static resources, Spring MVC will treat them as normal requests, so failure to find the corresponding processor will result in an error.
after configuring < mvc:default-servlet-handler / > in the springMVC-servlet.xml, an org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler, is defined in the Spring MVC context. It will, like an inspector, screen the URL entering the DispatcherServlet. If the request is found to be a static resource, it will be transferred to the default Servlet of the Web application server. If it is not a request for static resources, the DispatcherServlet will continue to process it.

the default Servlet name for a general Web application server is "default", so DefaultServletHttpRequestHandler can find it. If the default Servlet name of all your Web application servers is not "default", you need to specify through the default-servlet-name attribute:
< mvc:default-servlet-handler default-servlet-name= "the default Servlet name used by the Web server" / >
you can refer to the following article:
https://www.cnblogs.com/dflmg.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf4459-31efd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf4459-31efd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?