Java GET/WEB-INF/jsp/login.jsp没有映射

Java GET/WEB-INF/jsp/login.jsp没有映射,java,spring-boot,spring-mvc,Java,Spring Boot,Spring Mvc,请在GITHUB上查找此项目,如 即使遵循了正确的教程,我也会犯如下错误。请指引我哪里出了问题。请随意克隆该项目。我刚才犯了错 2021-04-23 20:45:38.227 INFO 16580 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2021-04-23 20:45:38.227

请在GITHUB上查找此项目,如

即使遵循了正确的教程,我也会犯如下错误。请指引我哪里出了问题。请随意克隆该项目。我刚才犯了错

2021-04-23 20:45:38.227  INFO 16580 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : 

Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-04-23 20:45:38.227  INFO 16580 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-04-23 20:45:38.229  INFO 16580 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2021-04-23 20:45:38.259  WARN 16580 --- [nio-8080-exec-1] o.s.web.servlet.PageNotFound             : No mapping for GET /WEB-INF/jsp/login.jsp

尝试添加
@EnableWebMvc
并在
应用程序配置
类中重写以下方法

    public void configureDefaultServletHandling(
            DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
(GitHub代码似乎与您的问题不匹配。)

尝试删除


您设置了模板解析器,但它似乎是错误的。

我创建了一个类InsertialData类,注释为
@Component
,并将
WebApplicationContext
自动连线
注释一起使用。ThymileAF使用上下文进行初始化,请在下面的代码中找到

@Component
public class InsertInitialData{

WebApplicationContext context;

@Autowired
public void setContext(WebApplicationContext context) {
    this.context = context;
}
@Bean //as it is from thymeleaf documentation, just passed the context! else is same!
public SpringResourceTemplateResolver templateResolver(){
    // SpringResourceTemplateResolver automatically integrates with Spring's own
    // resource resolution infrastructure, which is highly recommended.
    SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
    templateResolver.setApplicationContext(this.context);
    templateResolver.setPrefix("/WEB-INF/templates/");
    templateResolver.setSuffix(".html");
    // HTML is the default value, added here for the sake of clarity.
    templateResolver.setTemplateMode(TemplateMode.HTML);
    // Template cache is true by default. Set to false if you want
    // templates to be automatically updated when modified.
    templateResolver.setCacheable(true);
    return templateResolver;
}

@Bean
public SpringTemplateEngine templateEngine(){
    // SpringTemplateEngine automatically applies SpringStandardDialect and
    // enables Spring's own MessageSource message resolution mechanisms.
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(templateResolver());
    // Enabling the SpringEL compiler with Spring 4.2.4 or newer can
    // speed up execution in most scenarios, but might be incompatible
    // with specific cases when expressions in one template are reused
    // across different data types, so this flag is "false" by default
    // for safer backwards compatibility.
    templateEngine.setEnableSpringELCompiler(true);
    return templateEngine;
}

查看repo、克隆和运行,使用Spring boot run

无法运行您的项目,但遇到错误,``2021-04-23 17:50:11.628 INFO 28326---[extShutdownHook].SchemaDropperImpl$DelayedDropActionImpl:HHH000477:启动模式的延迟收回数据作为SessionFactory关闭的一部分'2021-04-23 17:50:11.634信息28326---[extShutdownHook]com.zaxxer.hikari.HikariDataSource:hikariol-1-已启动关闭。。。2021-04-23 17:50:11.637信息28326---[extShutdownHook]com.zaxxer.hikari.HikariDataSource:hikaripol-1-关闭完成```我们需要以某种方式运行“Spring boot run”,理想情况下运行足以复制您的案例的主类。不需要使用上述命令运行。