Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Spring提供静态Html文件,无法使用Spring安全性获取_Spring_Spring Mvc_Spring Boot_Spring Security - Fatal编程技术网

从Spring提供静态Html文件,无法使用Spring安全性获取

从Spring提供静态Html文件,无法使用Spring安全性获取,spring,spring-mvc,spring-boot,spring-security,Spring,Spring Mvc,Spring Boot,Spring Security,我有一个由html、js和css文件组成的restful应用程序。应用程序分为两个文件夹,常规文件夹和管理文件夹。我已将这两个文件夹放在Spring静态目录下 src/main/resources/static/regular src/main/resources/static/admin src/main/resources/static/regular/index.html 只需从以下位置更改配置文件: @Configuration public class WebConfig implem

我有一个由html、js和css文件组成的restful应用程序。应用程序分为两个文件夹,常规文件夹和管理文件夹。我已将这两个文件夹放在Spring静态目录下

src/main/resources/static/regular

src/main/resources/static/admin

src/main/resources/static/regular/index.html


只需从以下位置更改配置文件:

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/admin/**").addResourceLocations("/static/admin/");
        registry.addResourceHandler("/**").addResourceLocations("/static/regular/");

    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index.html");
    }

}
致:


您想通过/url映射获取index.html文件吗?是的,但到目前为止,即使键入也无法获取任何信息。您可以尝试localhost:8080/regular/index.html吗?访问资源时出现哪个http错误?出现意外错误(type=Not Found,status=404)。
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/admin/**").addResourceLocations("/static/admin/");
        registry.addResourceHandler("/**").addResourceLocations("/static/regular/");

    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index.html");
    }

}
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/regular/index.html");
    }

}