---
title: "spring boot 配置默认欢迎页"
author: "g21121"
date: "2018-03-14T18:38:08Z"
tags: []
categories: ["Web前端"]
slug: "spring-boot"
draft: false
lastmod: "2018-03-14T18:28:34Z"
id: 2413105
url: "https://286.iteye.com/blog/2413105"
---

```
@Configuration
@Controller
public class IndexConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/index.htm");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addViewControllers(registry);
    }

    @RequestMapping(value = "/index.htm", method = RequestMethod.GET)
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws IOException {
        ModelAndView view = new ModelAndView();
        view.setViewName("index");
        return view;
    }
}
```

         可以根据需求拆分成两个类。