在Spring Boot中无法解析名称为'index'的视图

mk工具:

春季启动:2.3.3.RELEASE

爪哇:11

我使用webflux + RouterFunction + Thymeleaf并遇到错误“无法解析名称为'index'的视图”。

index.html在“资源/模板”下。我把一些看起来很重要的源代码。

如果使用“ RouterFunction”,是否不能使用Thymeleaf?

如果您需要更多详细信息,请随时发表评论。

######## handler ###########
@Component
public class ItemHandler {

public RouterFunction<ServerResponse> routes = route()
        .path("/item", builder -> builder.GET("/", this::index))
        .build();

public Mono<ServerResponse> index(ServerRequest request) {
    Map<String, Object> attributes = new HashMap<>();
    attributes.put("items", "Hello");

    return ServerResponse.ok().contentType(MediaType.TEXT_HTML)
            .render("index", attributes);
}
}


######## index.html ###########
<!DOCTYPE html>
<html lang="ja"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<h1>FluxTest</h1>
</body>
</html>

######## entry point ###########
@SpringBootApplication
public class DemoWebfluxApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoWebfluxApplication.class, args);
    }
}
丹尼尔·雅各布:

负责处理静态文件位置的默认属性为spring.resources.static-locations

默认值为/META-INF/resources/, /resources/, /static/, /public/您可以覆盖默认值,也可以将其放在index.html这些位置之一。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Spring Boot Web入门视图位置

Java,Spring,Apache Tiles错误:无法在名称为“ dispatcher”的servlet中解析名称为“ index”的视图

Spring Boot找不到jsp视图

内部资源视图解析器在Spring Boot中不起作用

Spring无法解析servlet中的视图

Spring Boot中的InternalViewResolver无法找到视图

如果请求映射方法返回列表,Spring Boot如何解析视图名称?

无法在名称为“ dispatcherServlet”的servlet中解析名称为“ forward:/index.html”的视图

Spring Boot无法解析视图页面

Spring Mvc Java无法在名称为'dispatcher'的servlet中解析名称为'home'的视图

无法在Spring MVC中返回HTML视图

无法在名称为“ spring”的servlet中解析名称为“ streamrecords”的视图

Spring Boot无法从模板加载视图

EnableWebMvc引发ServletException:无法解析名称为的视图

Spring Security抛出javax.servlet.ServletException:无法解析名称为'j_spring_security_check'的视图

Spring Boot无法解析Freemarker视图

Spring Boot无法解析带有名称的视图

ils。无法在名称为“ grailsDispatcherServlet”的servlet中解析名称为“ index”的视图

spring.view.prefix:在Spring Boot中未应用于简单视图名称

无法在视图目录中查找视图“ index.ejs”

Spring:无法在Spring MVC中解析视图名称

在Spring Boot中创建名称为'batchConfigurer'的bean时出错

Spring Boot无法解析Thymeleaf视图

无法在视图目录“ / app / views”中查找视图“ home / index”

Spring MVC:无法渲染视图-$ {}在视图中渲染

无法解析名称为Y的servlet中名称为X的视图

无法在名称为'grailsDispatcherServlet'的servlet中解析名称为'/ hello / index'的视图

Spring Boot视图不起作用

javax.servlet.ServletException:无法解析名称为“NA-dispatcher”的servlet中名称为“login”的视图