表单封装:<form action="" method="post" enctype="multipart/form-data"></form>
在Servlet中都讲使用如下方式进行处理:
// 创建SmartUpload对象
SmartUpload smart = null;
// 当没有直接接收到status值,说明表单可能被封装了,
// 加入判断,当status为null时,使用smartUpload来接收此值
if (status == null) {
smart = new SmartUpload();
// 初始化
smart.initialize(this.getServletConfig(), request, response);
// 上传
try {
smart.upload();
} catch (SmartUploadException e) {
e.printStackTrace();
}
status = smart.getRequest().getParameter("status");
}
接受参数必须使用:smart.getRequest().getParameter("参数名称")