请教一下springboot如何设置默认的首页?

springboot如何设置默认的首页


隔江千里
浏览 2410回答 3
3回答

墨色风雨

1.spring boot中可以设置默认首页,当输入域名是可以自动跳转到默认指定的网页@Configurationpublic class DefaultView extends WebMvcConfigurerAdapter{@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/").setViewName("forward:/index");registry.setOrder(Ordered.HIGHEST_PRECEDENCE);super.addViewControllers(registry);}}

慕哥9229398

在你安装后的Apache目录下,有一个conf目录,在这个目录里,有一个"httpd.conf"文件.我们要做的,就是修改这个文件.在这个文件里,凡是以"#"开头的每一行,都是无效的,如果你想让你的设置起作用,就要把行首的"#"去掉.找到DirectoryIndex 这段.把它改成DirectoryIndex index.php index.Html index.html这样,你的网站目录的默认首页是 index.php, 如果没有index.php系统会自动寻找index.html、html做为默认首页了。注意事项:index.php index.Html之间要有一个空格另外你还可以操作一下其它的:找到ServerRoot 这段.将它设成你的Apache安装目录,我的是 ServerRoot "D:/Apache Group/Apache2"找到 DocumentRoot 这段.把他设成你网站的根目录,我的是 DocumentRoot "D:/Apache Group/web
打开App,查看更多内容
随时随地看视频慕课网APP