需要在spring-mvc.xml 视图解析器的配置文件中
增加如下配置,否则不会启用web.xml的默认欢迎页。或只能访问jsp页面的欢迎页。
<!--跳转到默认欢迎页面 不添加只能跳转到jsp页面-->
<mvc:default-servlet-handler/>
项目web.xml欢迎页面配置如下:
<welcome-file-list><!--指定欢迎页面-->
<welcome-file>/index.html</welcome-file>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
index.html 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 align="center" style="text-align: center; color: red">Hello World html</h1>
</body>
</html>
启动浏览器访问如下