尝试在 struts2 中上传图像时,图像未上传 msg Unable to find 'struts.multipart.saveDir' [英] While trying to upload the Image in struts2 the image is not uploading msg Unable to find 'struts.multipart.saveDir'
问题描述
尝试在 struts2 中上传图像时,图像未上传并显示以下 msg Unable to find 'struts.multipart.saveDir' 属性设置.默认为 javax.servlet.context.tempdir
While trying to upload the Image in struts2 the image is not uploading and showing following msg Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
推荐答案
您收到此消息是由于 S2 的构建 din 功能.您需要使用 告诉 S2 文件上传拦截器您要将上传的文件放置在何处struts.multipart.saveDir
属性在 struts.property
文件中或作为 struts.xml
文件中的常量,如
You are getting this message due to build din feature of S2.you need to tell S2 file upload interceptor where you want to place the uploaded file using struts.multipart.saveDir
property either in the struts.property
file or as a constant in struts.xml
file like
struts.multipart.saveDir=location of your choice
struts.xml 文件
<constant name="struts.multipart.saveDir" value="your location" />
如果未设置此属性,则默认为 javax.servlet.context.tempdir
.Sine S2 将上传文件放在临时目录中,以防您未指定 saveDir 但一旦该过程完成,为了清理过程,它将删除该临时文件,因此请确保您已设置 saveDir 参数,或者您应该在操作类中放置逻辑以从那里选择文件并将其移动到您选择的位置.
If this property is not set it defaults to javax.servlet.context.tempdir
.Sine S2 put the upload file in the temp directory in case you have not specified the saveDir but once the process complete, in order for the clean up process it will remove that temp file, so make sure either you have set the saveDir parameter or you should put logic in your action class to pick file from there and move it to your choice location.
有关S2文件上传的详细信息,请阅读官方文档
For details about S2 file upload read the official doc
这篇关于尝试在 struts2 中上传图像时,图像未上传 msg Unable to find 'struts.multipart.saveDir'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!