struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Yang <kenshin...@gmail.com>
Subject Re: uploading a .xls file
Date Thu, 10 Sep 2009 05:04:59 GMT
are u getting anything from the uploadContent?
because i think i should be

File file
String fileContentType
String fileFileName

On Thu, Sep 10, 2009 at 12:50 PM, KIRTI CHOPRA <kirtichopra2003@gmail.com>wrote:

>
> hi all
> i am new to struts and trying to upload a file in struts 2.0
> i am using <s:file> tag and have given simple getter setters in action
> class
> i am getting null value in file name pls help and let me know how i can do
> it.
> code is given below:
> Action class
>
> package com.neevtech.newsletter.action;
>
>  import java.io.File;
>
> /**
>  * Created by IntelliJ IDEA.
>  * User: Owner
>  * Date: Sep 9, 2009
>  * Time: 10:22:18 AM
>  * To change this template use File | Settings | File Templates.
>  */
> public class UploadXlsAction extends BaseAction {
>    private File file;
>    private String uploadContent;
>    private String fileName;
>
>    public String execute() throws Exception
>    {
>        this.file=getFile();
>        this.fileName=getFileName();
>        /*String filepath=file.getAbsolutePath();
>        System.out.println(filepath);*/
>        System.out.println(fileName);
>        return "success";
>    }
>    public File getFile() {
>        return file;
>    }
>
>    public void setFile(File file) {
>        this.file = file;
>    }
>
>    public String getUploadContent() {
>        return uploadContent;
>    }
>
>    public void setUploadContent(String uploadContent) {
>        this.uploadContent = uploadContent;
>    }
>
>    public String getFileName() {
>        return fileName;
>    }
>
>    public void setFileName(String fileName) {
>        this.fileName = fileName;
>        System.out.println(fileName);
>    }
>
>    public String uploaded(){
>        this.file=getFile();
>        this.fileName=getFileName();
>         System.out.println(fileName);
>        return "success";
>    }
>
> }
> Jsp page
>
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
>
>
> <div class="centertb">
>
>                <div class="subTitleText" style="padding-left: 50px;">
>                    <s:form method="POST" enctype="multipart/form-data"
> theme="simple">
>                            <table width="80%" style="font-weight: normal;">
>                    <tr>
>                        <td>
>                            <s:file name="file" label="File"></s:file>
>                        </td>
>                    </tr>
>                     <tr>
>                     <td><s:submit action="uploadXls"cssClass="submitButton"
> label="upload xls" align="left" cssStyle="margin-left:100px;"/></td>
>                 </tr>
>                </table>
>                    </s:form>
>                </div>
> </div>
>
> --
> View this message in context:
> http://www.nabble.com/uploading-a-.xls-file-tp25377242p25377242.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message