开发者

file upload problem in struts2

i want to upload a file and update result in other div on the same page dynamically just by showing a string "succeed/failed". It is working fine when i am forwarding result to a new page. However for below mentioned code it is updating div id "two" to [object HTMLDocument]. Please show me the way to solve it.

<div id='two' style="border: 1px solid yellow;"><b>initial content</b></div>
<s:form id='theForm2' cssStyle="border: 1px solid green;" enctype="multipart/form-data" action='doUpload' method='post' theme="ajax">
<input type="file" name="upload" />开发者_C百科
<s:submit value="GO2" theme="ajax" targets="two"/>
</s:form>


What type of file are you trying to upload?

For your action in your struts.xml file you need to have an action that has a result that is of type="stream"

<action name="myAction" class="com.MyJavaFileAction">

            <result name="SUCCESS" type="stream">

            <param name="contentType">image/jpeg</param>
            <param name="inputName">fileStream</param>
            <param name="contentDisposition">attachment;filename="${filename}"</param>
            <param name="bufferSize">1024</param>

            </result>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜