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?