java - 使用spring boot 1.5.8、Spring 4.3.21.RELEASE、tomcat 8.5.35时出现目录遍历问题
问题描述
使用 1.5.8 版本的 Spring-boot Web 应用程序时,我面临目录遍历问题,仅在 .war 扩展包中。
项目结构。
app.war-->
->css
->images
->js
->META-INF
->org-
->springframework->boot->loader->jar->Bytes.class
->WEB-INF
in which directly able to access.
http://localhost:3737/app/org/springframework/boot/loader/jar/Bytes.class
If I used 2.x of spring-boot then the issue is not comming.
Spring-boot-->1.5.8.RELEASE
Spring-mvc-->4.3.25.RELEASE
Spring-Security-->security-web-4.2.8.RELEASE
Tomcat-->tomcat-embed-core-8.5.35.jar
同样,我正在尝试使用 Spring Boot 使用 web.xml 安全约束来防止访问。 将 web.xml 安全约束与 Spring Boot 一起使用, 但同样不起作用
解决方案
这种行为在 Spring Boot 2.0 中得到了改进。Spring Boot 1.5已于 2019 年 8 月结束其受支持的生命周期,因此理想情况下,您应该升级到 Spring Boot 2.x。在撰写本文时,2.4.x 和 2.5.x 是受支持的世代。
如果您被困在 Spring Boot 1.5 上,您的选择就会受到限制。您可以使用 jar 打包,也可以构建一个普通的 war 文件(不能使用 运行的文件java -jar
)并将其部署到 Tomcat(或另一个 servlet 容器)。您也可以使用Filter
404 来响应不需要的请求。
推荐阅读
- java - 从同一项目/服务连接到 2 个模式的正确方法是什么?
- sql - 用“;”分隔的每个值创建新列 SQL Server 子字符串
- java - (HackerRank Day 2: Operators) 构造函数的问题
- magento - 更改购物车中的产品名称,报价单,发票 Magento 2
- php - docker 中的 Composer 私有存储库
- r - 在 R 过滤器中,一个表的行基于与另一个表的匹配和日期小于另一个表
- json - 如何将 I18n 实现为 JPA 或 Hibernate 实体的 JSON 对象?
- bash - 自定义编写的 Nagios 插件总是返回不正确的值,但在命令行上工作
- sql - postgresql - 将间隔格式化为具有大量小时数的时间
- javascript - 如何检测浏览器的chrome