为什么在尝试使用组件上传文件后,我总是得到Null

时间:2012-09-13 01:54:04

标签: java jsf file-upload

xhtml的代码如下:

    <h:form enctype="multipart/form-data" id="importForm">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>
                    <t:inputFileUpload id="upFile"
                        title="#{messages['global.label.import.browse']}"
                        value="#{attachmentAction.upFile}" storage="file"
                        maxlength="1000000">
                    </t:inputFileUpload>
                </td>
            </tr>
            <tr>
                <td>
                    <h:commandButton action="#{attachmentAction.upload}" value="#{messages['button.upload']}" 
                        styleClass="btnCla" onclick="return checkSelectFile();" type="submit">
                    </h:commandButton>
                </td>
            </tr>
        </table>
    </h:form>

Action方法的代码如下。我只是想从客户那里得到一个excel。

public void upload(){
    try {
        jxl.Workbook wb = Workbook.getWorkbook(upFile.getInputStream());// Here , I always got Null for the value of upFile! Why?
        wb.getSheet(0);
    } catch (Exception e) {

    }
}

我总是因为upFile的价值而获得Null!为什么呢?

0 个答案:

没有答案