为什么没法传值过去?
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
String uploadPath = "D:\\Eclipse_javaEE\\LastMaybe\\WebContent\\imgs";
String fileName=null;
PrintWriter out=response.getWriter();
dataRealize doit=new dataRealize();
try {
if (ServletFileUpload.isMultipartContent(request)) {
DiskFileItemFactory disk = new DiskFileItemFactory();
ServletFileUpload up = new ServletFileUpload(disk);
List<FileItem> list = up.parseRequest(request);
Iterator<FileItem> i=list.iterator();
String nameNo=request.getParameter("trueName");//这里获取值
out.print(nameNo);//可是没法输出,得到的是null值
while (i.hasNext()) {
FileItem fileItme = (FileItem) i.next();
if (!fileItme.isFormField()) {
String filePath = fileItme.getName();
fileName = "";
int startIndex = filePath.lastIndexOf("\\");
if (startIndex!=-1) {
fileName = filePath.substring(startIndex+1);
}else {
fileName = filePath;
}
File saveFile = new File(uploadPath,fileName);
try {
fileItme.write(saveFile);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
} catch (FileUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
相关推荐
React传值 组件传值 之间的关系详解
主要介绍了React传值 组件传值 之间的关系详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
两个controller相互传值
IOS实现在两个ViewController间传值
PHP传值到不同页面的三种常见方式及php和html之间传值问题
主要介绍了PHP传值到不同页面的三种常见方式及php和html之间传值问题的相关资料,需要的朋友可以参考下
vue prop属性传值与传引用示例
vue组件在prop里根据type决定传值还是传引用。 简要如下: 传值:String、Number、Boolean 传引用:Array、Object 若想将数组或对象类型也以值形式传递怎么办呢?如下方式可以实现: // component-A 引用component-B组件 // component-A 部分关键代码 // 将数组复制,personBak与personList是两个“内容”相同但地址不一样的对象(数组), // 这
C语言中传值与传指针的介绍与区别
前言 我们可能听过C语言中的传值和传指针,在其他语言中,也有传引用一说,那么他们到底有什么区别呢?如果你还不能准确地分辨,就该好好了解一下了。 传值 我们在初学C语言的时候就被老师教过,下面的方式是无法交换a和b的值的: #include<stdio> void swap(int a,int b) { int temp = a; a = b; b = temp; printf(swap a = %d,b = %d\n,a,b); } int main(void) { int a = 10; int b = 20; printf(before swap:a = %d


