Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 upload problem

 
Winson Sun
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

can you please help us ?

Thanks

Rahul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic