我有一个带有文件上传选项的网络表单。我使用multipart/form-data
作为enctype和post方法来提交表单。在服务器端,我正在使用struts2动作类。请找到以下代码。
JSP:
<s:form action="createAdvertisement" id="heRegistration" theme="simple"
name="advertisementForm" validate="true" method="post"
enctype="multipart/form-data">
<s:hidden name="lastAccessTime" id="lastAccessTime"></s:hidden>
<table width="520px" border="0" cellspacing="0" cellpadding="0"
class="formStyles">
<tr height="35">
<td><s:text name="global.Advertisment" /><span
class="important"> *</span></td>
<td>:</td>
<td><input type="file" name="imageUpload"> <span
id="vMsg"
style="position: relative; top: -26px; width: 360px; height: 22px; color: red;">
</span></td>
</tr>
<tr>
<td></td>
<td></td>
<td><span class="tableErrorSpan"> <s:fielderror
cssStyle="font-size:10px;" fieldName="imageUpload"></s:fielderror></span>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td id="removeButton"><span id="errAdd" class="tableErrorSpan"></span></td>
</tr>
<tr height="35">
<td> </td>
<td> </td>
<td><input type="submit" class="btn btnIEfix"
value="<s:text name="button.save"/>"
name="action:createAdvertisement" alt="Save"> <input
type="button" name="cancel" class="btn btnIEfix btnInline"
onclick="location.href='cancelAdvertisement.action'"
value="<s:text name="button.cancel"/>" /></td>
</tr>
</table>
</s:form>
Struts配置:
<action name="createAdvertisement" method="createAdvertisement"
class="categoryAdvertisementsAction">
<interceptor-ref name="fileUploadStack" />
<result name="success">jsp/admin/addSuccess.jsp</result>
<result name="input">jsp/admin/createAdvertisments.jsp</result>
</action>
动作类代码行接受输入文件:
private File imageUpload;
final BufferedImage originalImage = ImageIO.read(imageUpload);
该表单已在某些PC中提交但未在某些PC中提交。我需要知道为什么会发生这种情况以及enctype是否在硬件上有任何依赖性。
更新
@Konza:请在下面找到原始html。
<form enctype="multipart/form-data" method="post" action="createAdvertisement.action" name="advertisementForm" id="heRegistration">
<table width="95%" cellspacing="0" cellpadding="0" border="0" class="formStyles">
<tbody>
<tr height="35">
<td>Advertisement<span class="important"> *</span></td>
<td>:</td>
<td><input type="file" name="imageUpload" id="filestyle-0" style="position: fixed; left: -500px;"><div style="display: inline;" class="bootstrap-filestyle"><input type="text" disabled="" class="input-large"> <label class="btn" for="filestyle-0"><i class="icon-folder-open"></i> <span>Browse</span></label></div>
<span style="position: relative; top: -26px; width: 360px; height: 22px; color: red;" id="vMsg">
</span>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<span class="tableErrorSpan">
</span>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td id="removeButton"><span class="tableErrorSpan" id="errAdd"></span></td>
</tr>
<tr height="35">
<td> </td>
<td> </td>
<td>
<input type="submit" alt="Save" name="action:createAdvertisement" value="Save" class="btn btnIEfix">
<input type="button" value="Cancel" onclick="location.href='cancelAdvertisement.action'" class="btn btnIEfix btnInline" name="cancel">
</td>
</tr>
</tbody></table>
</form>
@Andrea Ligios:所有的PC都落后于代理。
@Aleksandr M:表单提交没有到达相关的struts动作类,因为我使用eclipse调试代码,因此服务器端验证不起作用。