Websphere liberty 是否正确使用了 MultiPartConfig 位置?

Is Websphere liberty using MultiPartConfig location correctly?

来自 JavaDocs:

The @MultipartConfig annotation supports the following optional attributes:

location: An absolute path to a directory on the file system. The location attribute does not support a path relative to the application context. This location is used to store files temporarily while the parts are processed or when the size of the file exceeds the specified fileSizeThreshold setting. The default location is "".

然而,当

location="\Temp"

正在上传的文件位于:

\Servers\IBM\wlp\usr\servers\app\workarea\org.eclipse.osgi3\data\temp\default_node\SMF_WebContainer\app-ear\app-1.0-SNAPSHOT\Temp\upload__4529d7ce_15f90e11b66__7ff3_00000002.tmp

这不是配置中给出的绝对路径。

我们如何指定正确的文件夹?

更新:

请参阅下面保罗的回答。指定 'C:/Temp' 作为位置就成功了。

Servlet 3.0 规范在@MultipartConfig 的描述中相当模糊。然而,最新版本的 Servlet 规范声明如下:

The location attribute of the javax.servlet.annotation.MultipartConfig and the element of the is interpreted as an absolute path and defaults to the value of the javax.servlet.context.tempdir. If a relative path is specified, it will be relative to the tempdir location. The test for absolute path vs relative path MUST be done via java.io.File.isAbsolute.

在这种情况下,平台 Windows 之所以重要是因为 java.io.File.isAbsolute() 行为取决于所使用的 OS:

所以在您的情况下 isAbsolute() 似乎返回 false,如果您遵循文件 JavaDoc 中的指南,您应该能够在您想要的地方获取文件。