当前位置: 代码迷 >> J2EE >> JSPSmartUpload 用getrequest方法获得的值还是NULL,求解,先谢了解决方法
  详细解决方案

JSPSmartUpload 用getrequest方法获得的值还是NULL,求解,先谢了解决方法

热度:615   发布时间:2016-04-22 01:59:26.0
JSPSmartUpload 用getrequest方法获得的值还是NULL,求解,先谢了
内容如下
<%@page   contentType= "text/html;charset=gb2312 "%>
<%
          request.setCharacterEncoding( "gb2312 ");
%>

<html>
<body>
<FORM   METHOD= "POST "   ACTION= "MyJsp.jsp "   ENCTYPE= "multipart/form-data ">  
<INPUT   TYPE= "text "   NAME= "FILE0 "   SIZE= "50 "> <BR>  
<INPUT   TYPE= "FILE "   NAME= "FILE1 "   SIZE= "50 "> <BR>  
<INPUT   TYPE= "FILE "   NAME= "FILE2 "   SIZE= "50 "> <BR>  
<INPUT   TYPE= "FILE "   NAME= "FILE3 "   SIZE= "50 "> <BR>  
<INPUT   TYPE= "FILE "   NAME= "FILE4 "   SIZE= "50 "> <BR>  
主题: <input   type= "text "   name= "text1 "   > <br>  
<INPUT   type=submit   value=写 完   name=ok>  
</form>  
</body>
</html>


获取 <%@page   contentType= "text/html;charset=gb2312 "  
language= "java "  
import= "com.jspsmart.upload.* "%>  


<HTML>  
<BODY   >  
<H1> 文件上传JSP </H1>  
<HR>  
<%  
SmartUpload   mySmartUpload   =   new   SmartUpload();
int   count=0;  
String   m   =   mySmartUpload.getRequest().getParameter( "FILE0 ");
out.println(99998888+m);
//定义目标目录  
//String   destination= "/upload/ ";  
mySmartUpload.initialize(pageContext);  

//文件上传  
mySmartUpload.upload();  
//获得文本的内容  
String   content   =   mySmartUpload.getRequest().getParameter( "text1 ");  
//显示文本的内容  
out.println(content);  
//上传的情况统计  
for   (int   i=0;i <mySmartUpload.getFiles().getCount();i++){  
com.jspsmart.upload.File   myFile   =   mySmartUpload.getFiles().getFile(i);  
if   (!myFile.isMissing()){  
myFile.saveAs(myFile.getFileName(),2);  
out.println( "文件名称=   "   +   myFile.getFieldName()   +   " <BR> ");  
out.println( "文件大小=   "   +   myFile.getSize()   +   " <BR> ");  
out.println( "文件名称=   "   +   myFile.getFileName()   +   " <BR> ");  
out.println( "文件大小=   "   +   myFile.getFileExt()   +   " <BR> ");  
out.println( "文件路径名=   "   +   myFile.getFilePathName()   +   " <BR> ");  
out.println( "文件类型=   "   +   myFile.getContentType()   +   " <BR> ");  
out.println( "ContentDisp   =   "   +   myFile.getContentDisp()   +   " <BR> ");  
out.println( "MIME类型   =   "   +   myFile.getTypeMIME()   +   " <BR> ");  
out.println( "SubTypeMIME   =   "   +   myFile.getSubTypeMIME()   +   " <BR> ");  
count   ++;  
  相关解决方案