我有一个以下 JSP:
<form action="UploadServlet" method="post" enctype="multipart/form-data">
Select file to upload: <input type="file" name="file" id =upfile"size="50" /> <input type="button" value="Save" onclick="javascript:uploadPartnerDetails();" class="buttons">
</form>
以及调用远程 Java 方法的 DWR 脚本:
function uploadPartnerDetails() {
SMUDWR.uploadPartnerDetails(function(data) {
dwr.util.setValue("UserTypeDiv", data, {
escapeHtml: false
});
});
}
远程方法 uploadPartnerDetails() 是:
try {
WebContext wctx = WebContextFactory.get();
HttpServletRequest request = wctx.getHttpServletRequest();
// checks if the request actually contains upload file
if (!ServletFileUpload.isMultipartContent(request)) {
// if not, we stop here
}
我得到这个错误:
请求不包含 multipart/form-data 或 multipart/form-data 流,内容类型标头为 text/plain
问题是上面的请求不包含多部分/表单数据。我如何从这个请求中得到它?