gpt4 book ai didi

java - 如何使 thymeleaf spring 安全命名空间可用?

转载 作者:行者123 更新时间:2023-11-30 07:54:08 26 4
gpt4 key购买 nike

我有一个 Spring Boot 应用程序。据我了解,启动应用程序只需要 pom 中的依赖项,一切都很好。不幸的是,情况并非如此,即使我的配置过于复杂,它仍然不起作用 - 我无法使用 sec我的页面中的命名空间。

在我的页面中,第一个问题是命名空间 URI:

enter image description here

我已经尝试了 Intellij 修复菜单中的所有可用选项,但无法解决。

我想这个问题的结果是我无法使用 sec任何地方的命名空间。图中的示例可能确实是无效使用,但我使用过 <div>以及直接来自 Thymeleaf 示例的内容:

enter image description here

这里的许多答案和其他来源也依赖于 xml 配置,这是没有用的。尽管如此,我还是根据这些 xml 示例制作了基于 Java 的 bean,但没有成功。

仅使用基于Java的配置(如果是的话)在 Spring Boot 应用程序中使用 Spring Security 和 thymeleaf 集成需要执行哪些步骤?

pom.xml

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
...
</dependencies>

最佳答案

我遇到了同样的问题,对我来说它有助于定义这样的架构位置:

<html lang="en"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.thymeleaf.org http://www.thymeleaf.org
http://www.ultraq.net.nz/thymeleaf/layout http://www.ultraq.net.nz/thymeleaf/layout
http://www.thymeleaf.org/thymeleaf-extras-springsecurity4 http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">

...

这还包括布局和 spring security 4 的其他方言,如果您不使用它们,可以将其删除。

关于java - 如何使 thymeleaf spring 安全命名空间可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32917308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com