spring root 配置wwwroot静态文件目录 并且默认打开wwwroot下的indexhtml文件
要在spring root中配置wwwroot静态文件目录并且默认打开wwwroot下的index.html文件,可以按照以下步骤进行操作:
- 在spring root配置文件中加入以下配置:
<mvc:resources mapping="/static/**" location="/wwwroot/"/>
<mvc:view-controller path="/" view-name="forward:index.html"/>
这里使用了mvc:resources标签来指定静态资源的映射路径和实际存放路径,同时使用了mvc:view-controller标签来指定访问根路径"/"时要跳转到的视图名称"index.html"。
-
在wwwroot目录下创建index.html文件,并填充内容。
-
启动spring应用程序,访问http://localhost:8080/即可看到index.html文件的内容。
原文地址: https://www.cveoy.top/t/topic/hfQS 著作权归作者所有。请勿转载和采集!