Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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/1/ms-access/4.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_Html_Spring_Spring Boot - Fatal编程技术网

Spring引导和普通html

Spring引导和普通html,html,spring,spring-boot,Html,Spring,Spring Boot,有没有人将spring boot调优为不带thymeleaf的查看纯html? 以下是我的配置: @SpringBootApplication @EnableAutoConfiguration @ComponentScan @Configuration @EnableWebMvc public class WebUi extends WebMvcConfigurerAdapter { @Bean public InternalResourceViewResolver getI

有没有人将spring boot调优为不带thymeleaf的查看纯html? 以下是我的配置:

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
@Configuration
@EnableWebMvc
public class WebUi extends WebMvcConfigurerAdapter {


    @Bean
    public InternalResourceViewResolver getInternalResourceViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/");
        resolver.setSuffix(".html");
        return resolver;
    }


        @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("login");
    }
//
//    @Override
//    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
//        configurer.enable();
//    }

    public static void main(String[] args) {
        SpringApplication.run(WebUi.class, args);
    }
}
我尝试过启用DefaultServletHandler和不启用。html文件放在src/main/resources/WEB-INF/login.html中并已组装。我在调试中的类路径中看到它。但请求返回404。
我做错了什么?

删除所有注释,只留下
@SpringBootApplication

删除
InternalResourceViewResolver
,只需将以下内容添加到
应用程序.properties

spring.view.prefix=/WEB-INF/
spring.view.suffix=.html
由于
@EnableWebMvc
,您当前的应用程序类会干扰Spring引导自动配置。下一步
@SpringBootApplication
已经暗示
@Configuration
@EnableAutoConfiguration
@ComponentScan
无需再次添加它们

添加
spring.view.*
properties时,spring Boot已经为您配置了
InternalResourceViewResolver


这里的基本建议是使用框架,而不是围绕/反对框架

一个可能有帮助的提示:安装执行器并打开/mappingsThanks,@Marged。我看到了终点。我想问题不在控制器层。视图有问题。通过嵌入式tomcat服务器运行或使用外部应用服务器?删除所有注释,仅通过嵌入式服务器保留
@SpringBootApplication
@KarthikPrasad