当我使用enctype =“multipart / form-data”进行上传和输入时,许多数据都为null,如果删除enctype =“multipart / form-data”,它可以获取数据但是上传为null。我的代码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。
答案 0 :(得分:0)
如果您需要上传稍后要添加的文件,那么您应该在servlet上放置@MultipartConfig注释,以便request.getParameter()可以工作,并且所有上传的文件都可以通过request.getPart()。@MultipartConfig(maxFileSize = 1073741824)
答案 1 :(得分:-1)
@MultipartConfig(maxFileSize = 1073741824)将此注释放在方法上