【发布时间】:2020-11-11 06:34:10
【问题描述】:
我是 Spring 新手并开始从 3.0.5 升级到 3.2.18,我尝试修改版本并将工件 ID 更改为新版本(例如 org.springframework.core 到 spring-core,等)并在声明中将 XSD 版本从 3.0 更新到 3.2。我在 applicationcontext-security.xml 中遇到了一个拦截 URL 问题
<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true">
<custom-filter position="FORM_LOGIN_FILTER" ref="authenticationProcessingFilter"/>
<custom-filter position="LAST" ref="loadUserContextFilter"/>
<logout logout-url="/static/j_spring_security_logout" logout-success-url="/login" />
<!-- Configure these elements to secure URIs in your application -->
....
...
..
<intercept-url pattern="/admin/campus/buildings/new" access="hasAnyRole('ROLE_RES.APP.CAMPUS.ADMIN_DEV','ROLE_RES.APP.CAMPUS.ADMIN_FULL')"/>
<intercept-url pattern="/admin/campus/buildings/*/sitesofservice/new" access="hasAnyRole('ROLE_RES.APP.CAMPUS.ADMIN_DEV','ROLE_RES.APP.CAMPUS.ADMIN_FULL')"/>
.....
<intercept-url pattern="/admin/**" access="hasAnyRole('ROLE_RES.APP.CAMPUS.ADMIN_FULL','ROLE_RES.APP.CAMPUS.ADMIN_DEV','ROLE_RES.APP.CAMPUS.ADMIN_DIFF')"/>
<intercept-url pattern="/batch/**" access="hasRole('ROLE_RES.APP.CAMPUS.ADMIN_BATCH')"/>
<intercept-url pattern="/resources/**" filters="none" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/**" access="permitAll" />
在上述文件中,
我尝试了不同的方法,删除了 filters="none" 并使用 security=none 创建了一个新的 http 属性,但它们都不起作用。
我提到了以下选项 https://www.baeldung.com/security-none-filters-none-access-permitAll#security-none 并添加了一个新的 http 元素,但仍然没有运气。
经过上述修改后,文件如下所示
<http pattern="/resources/**" security="none"/>
<http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true">
...
...
应用程序正在成功构建和部署,但没有加载图像、CSS 和 JS。日志中没有出现任何错误(我通过创建新的本地 tomcat 服务器来使用 IntelliJ 来部署和测试应用程序)
感谢任何帮助!
【问题讨论】:
-
请说明您是如何在 html 中引用 css 或图像
-
附加web-app结构在header.jspx中添加如下图片
-
这很有帮助,但我想看看你是如何在 html 中编写
<link href="../styles/main.css" rel="stylesheet">行代码的。 html文件也在哪个文件夹中? -
下面是 default.jspx 和 login.jspx 中的代码(文件位于 src/main/webapp/WEB-INF/layouts/
标签: spring spring-security upgrade javabeans spring-3