File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts 2 upload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 upload problem" Watch "struts 2 upload problem" New topic
Author

struts 2 upload problem

Winson Sun
Greenhorn

Joined: Oct 29, 2007
Posts: 2
When i use struts 2 upload file , in action, i can't get the upload file value. Can anybody help me? thanks in advance.

upload.jsp

<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<title>upload</title>
</head>
<body>
<s:form action="upload" method="POST" enctype="multipart/form-data">
<s:file name="uploads" label="upload file 1" /><br>
<s:file name="uploads" label="upload file 2" /><br>
<s:submit/>
</s:form>
</body>
</html>


UploadAction.java

public class UploadAction extends ActionSupport {

/**
*
*/
private static final long serialVersionUID = 1L;

private File[] uploads; // The actual file

private String[] uploadsContentType;// The content type of the file

private String[] uploadsFileName;// The uploaded file name and path

... ...

struts.xml
<action name="upload" class="com.pcz.spms.struts.UploadAction"
method="execute">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/png,image/gif,image/jpeg
</param>
<param name="maximumSize ">
102400
</param>
</interceptor-ref>
<!--<interceptor-ref name ="defaultStack"/> -->
<result name="success">/display.jsp</result>
</action>

in aciton, uploads value is null.
[ October 30, 2007: Message edited by: Winson Sun ]
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138

I also have the same problem.... For Large Size File the property value null!

can you please help us ?

Thanks

Rahul
 
 
subject: struts 2 upload problem