使用Struts2中的<s:file>上傳文件 - file uploading using <s:file> in Struts2 -开发者知识库

使用Struts2中的<s:file>上傳文件 - file uploading using <s:file> in Struts2 -开发者知识库,第1张

I am working on struts2 application. I have following in my jsp (say main.jsp) –

我正在研究struts2應用程序。我跟隨我的jsp(比如main.jsp) -

<s:file name="sampleDocument"/>
<s:submit action="uploadSample" value="Upload" />

See here how my struts.xml handling the action -

看看我的struts.xml如何處理動作 -

<action name=" uploadSample " class=" UploadFiles">                 
        <result name="success"> /main.jsp</result>
        <result name="input"> /error.jsp</result>
</action> 

Its all running well. As required file is uploading. But as you have seen I am calling same jsp page (i.e main.jsp) on SUCCESS. Its coming but <s:file> textbox in empty. I mean its there is no file name that I have browse before uploading. Can anyone know how to get this?

它運行良好。根據需要上傳文件。但正如你所看到我在SUCCESS上調用相同的jsp頁面(即main.jsp)。它即將出現,但 文本框為空。我的意思是它在上傳之前沒有我瀏覽過的文件名。誰能知道如何獲得這個?

3 个解决方案

#1


You need properties on your action that reflect the names of the parameters in your JSP. Have a look at this documentation for an explanation of which properties to look for.

您需要在操作中使用反映JSP中參數名稱的屬性。請查看此文檔以獲取要查找的屬性的說明。

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复