且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过 Java EE Web 应用程序将文件存储在服务器(Web 容器)上?

更新时间:2023-12-03 13:54:28

真的不推荐从 Java EE 容器写入文件系统,特别是如果您需要处理写入的数据:

Writing to the file system from a Java EE container is not really recommended, especially if you need to process the written data:

  • 它不是事务性的
  • 它损害了可移植性(如果您在集群环境中会怎样)
  • 需要为目标位置设置外部参数

如果这是一个选项,我会将文件存储在数据库中或使用 JCR 存储库(例如 Jackrabbit).

If this is an option, I would store the files in database or use a JCR repository (like Jackrabbit).