当我使用enctype=“multipart/form- data”上传时,输入的许多数据都为空,如果删除enctype=“multipart/form- data”,则可以获取数据,但上传的数据为空。我的代码html
<form action="createvendor" method="post" enctype="multipart/form-data">
<div>
<label> <input placeholder="Username:" type="text"
name="username" tabindex="1" >
</label>
</div>
<div>
<label> <input placeholder="Password" type="password"
name="password" tabindex="2" >
</label>
</div>
<div>
<label> <input placeholder="Firstname:" type="text"
name="firstname" tabindex="3" >
</label>
</div>
<div>
<label> <input placeholder="Lastname:" type="text"
name="lastname" tabindex="4" >
</label>
</div>
<div>
<label> <input placeholder="ID card:" type="text"
name="personalID" tabindex="5" maxlength="13"
onKeyUp="if(isNaN(this.value)){ alert('กรุณากรอกตัวเลข 13 หลักเท่านั้น'); this.value='';}"
>
</label>
</div>
<div class="registration_form">
<div style="position: relative;">
<a class='btn btn-primary'> Choose your ID card picture <input
required class="form-control" type="file"
style='position: absolute; z-index: 2; top: 0; left: 0; filter: alpha(opacity = 0); -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; opacity: 0; background-color: transparent; color: transparent;'
name="picturePersonalID"
onchange='$("#upload-file-info").html($(this).val());'>
</a> <span class='label label-info' id="upload-file-info"></span>
</div>
</div>
</form>我想上传和输入许多数据,并将数据发送到servlet。
发布于 2015-12-10 21:00:16
如果需要上传稍后要添加的文件,则应该在servlet上放置@MultipartConfig注释,以便request.getParameter()能够工作,并且request.getPart()可以检索所有上传的文件。@MultipartConfig(maxFileSize = 1073741824)
发布于 2015-12-10 20:54:55
@MultipartConfig(maxFileSize = 1073741824)将此注释放在方法上
https://stackoverflow.com/questions/34202258
复制相似问题