使用Spring Boot MVC为文件夹请求提供index.html内容

时间:2015-11-20 14:40:48

标签: spring-mvc spring-boot

请帮助我,我正在尝试使用spring应用程序来提供静态内容和数据库api请求,所以这是我的主要类:

@Configuration
@EnableAutoConfiguration
@EntityScan(basePackages = { "domain" })
@EnableJpaRepositories(basePackages = { "repository" })
@ComponentScan(basePackages = { "configuration" })
public class Application {
    private static final Log log = LogFactory.getLog(Application.class);
    private static Class<Application> applicationClass = Application.class;

    public static void main(String[] args) {
        SpringApplication.run(applicationClass, args);
    }
}

package configuration;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "controller" })
public class ServerConfiguration extends WebMvcAutoConfiguration {
}

package configuration;

@Configuration
public class RestRepositoryConfiguration extends RepositoryRestConfigurerAdapter {

    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
        super.configureRepositoryRestConfiguration(config);
        config.setBasePath("/api");
    }
}

如何在文件夹/ index.html响应中使用static / folder / index.html进行spring响应?

0 个答案:

没有答案