有特殊问题的。
我正在使用formpanel将数据发送到数据库并上载文件。
在chrome中,这很好,但在firefox中,它将数据发送到数据库,但不上传文件。firebug返回以下错误:

Form contains a file input, but is missing method=POST and enctype=multipart/form-data on the form.  The file will not be sent.

我觉得很奇怪。
检查了页面源代码,一切看起来都很好:
<form target="FormPanel_revanweb_1" action="phpFiles/newBookmark.php" enctype="ENCODING_MULTIPART" method="POST" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;" class="gwt-TabLayoutPanelContent">

这就是我使用uibinder构建表单面板的方式:
<g:FormPanel ui:field="formPanel" action="phpFiles/newBookmark.php" method="POST" encoding="ENCODING_MULTIPART">
    <g:VerticalPanel ui:field="tabNewWrapper" stylePrimaryName="tabNew-wrapper">
        <g:HTMLPanel ui:field="bookmarkNamePanel" styleName="container">
            <g:Label text="Bookmark Name:" />
            <g:TextBox name="txtBookmarkName" ui:field="txtBookmarkName" width="100%" />
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="bookmarkURLPanel" styleName="container">
            <g:Label text="Bookmark URL:" styleName="label" />
            <g:TextBox name="txtBookmarkURL" ui:field="txtBookmarkURL" width="100%" />
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="bookmarkDescriptionPanel" styleName="container">
            <g:Label text="Bookmark Description" styleName="label" />
            <g:TextArea name="txtBookmarkDescription" ui:field="txtBookmarkDescription" width="100%" height="60px" />
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="bookmarkImgUploadPanel" styleName="container">
            <g:Label text="Image:" styleName="label" />
                <g:VerticalPanel ui:field="vpForm">
                    <g:FileUpload name="logo" ui:field="uploadFile" />
                </g:VerticalPanel>
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="bookmarkcbActivePanel" styleName="container">
            <g:CheckBox  name="cbActive" ui:field="cbActive" text="Active?" styleName="label" />
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="bookmarkTagsPanel" styleName="container">
            <g:Label text="Tags:" styleName="label" />
            <g:SuggestBox ui:field="sbBookmarkTags" animationEnabled="true" width="100%" />
        </g:HTMLPanel>
        <g:HTMLPanel ui:field="btnOKPanel" styleName="container">
            <g:SubmitButton ui:field="btnSubmit" text="OK" styleName="buttonOK" />
            <g:Label ui:field="lblWarning" visible="false" styleName="warning" />
            <g:Hidden ui:field="sessionID" name="sessionid" visible="false" />
        </g:HTMLPanel>
    </g:VerticalPanel>
</g:FormPanel>

最佳答案

您正在将编码设置为ENCODING_MULTIPART,而不是multipart/form-data
NB:ENCODING_MULTIPART是一个常量类型String,它不是一个枚举;setEncoding on cc>以FormPanel为参数;因此,如果在uI.xml中编写EnCONDIGIN多个部分,则将字符串设置为String,而不是"ENCODING_MULTIPART"常量的值(BTW,只能在U.xml中引用FormPanel.ENCODING_MULTIPART,然后用作<ui:import field="com.google.gwt.user.client.ui.FormPanel.ENCODING_MULTIPART" />

09-28 09:46