request传值的问题 又是得不到想要的值
工作平台:myeclipse5.1+tomcat5.5
原来用jspsmartupload把图片和信息一起传的
后来把图片上传与信息传递分开,信息传递部分依然传不了值,
我已经把enctype= "multipart/form-data删了
[解决办法]
是不是一个页面添加商品,然后嵌入一个jspsmartupload,上传个图片获得图片地址?
给你段代码看吧,用iframe嵌入,然后用JS获取上传地址
产品添加页面:
<form name= "form1 " action= "Product " method= "post ">
<input name= "type " type= "hidden " value= "addproduct " />
<table class= "tableBorder " align= "center " border= "0 " cellpadding= "2 " cellspacing= "1 " width= "96% ">
<tbody>
<tr>
<th height= "25 " colspan= "2 "> 产品发布 </th>
</tr>
<tr>
<td width= "23% " height= "23 " align= "right " class= "TableRow2 "> 产品名称: </td>
<td width= "77% " class= "TableRow2 "> <input name= "title " type= "text " size= "60 "> </td>
</tr>
<tr>
<td width= "23% " height= "23 " align= "right " class= "TableRow2 "> 产品添加日期: </td>
<td width= "77% " class= "TableRow2 "> <input name= "date " type= "text " size= "60 " value= " <%=new java.sql.Date(new java.util.Date().getTime())%> "> </td>
</tr>
<tr>
<td width= "23% " height= "23 " align= "right " class= "TableRow2 "> 产品添加人员: </td>
<td width= "77% " class= "TableRow2 "> <input name= "author " type= "text " size= "60 " value= "admin "> </td>
</tr>
<tr>
<td width= "23% " height= "23 " align= "right " class= "TableRow2 "> 产品缩略图片: </td>
<td width= "77% " class= "TableRow2 "> <input name= "pic " type= "hidden " id= "pic " size= "30 " />
<iframe src= "upload.jsp " name= "UpLoad_Ad " width= "100% " height= "22 " scrolling= "no " frameborder= "0 " id= "UpLoad_Ad "> </iframe> </td>
</tr>
<tr>
<td width= "23% " colspan= "2 " height= "23 " align= "center " class= "TableRow2 "> 产品简介: </td>
</tr>
<tr>
<td height= "23 " colspan= "2 " class= "TableRow2 ">
<FCK:editor id= "content " basePath= "../FCKeditor/ " height= "440 "> </FCK:editor> </td>
</tr>
<tr>
<td height= "23 " colspan= "2 " align= "center " class= "TableRow2 ">
<input type= "submit " name= "Submit " value= "提交 "> <input type= "reset " name= "Submit " value= "重置 "> </td>
</tr>
</tbody>
</table>
</form>
upload.jsp
<div align= "left ">
<FORM METHOD= "POST " ACTION= "upfile.jsp " ENCTYPE= "multipart/form-data ">
<input type= "hidden " name= "test " value= "upload ">
<input type= "FILE " name= "FILE1 " size= "30 ">
<input type= "submit " name= "Submit " value= "上传 ">
</FORM>
</div>
upfile.jsp
<%
Random rd = new Random();
Calendar time = Calendar.getInstance();
SmartUpload su = new SmartUpload();
//初始化上传
su.initialize(pageContext);
//定义允许上传文件类型
su.setAllowedFilesList( "gif,jpg,rar,zip,doc,txt ");
//不允许上传文件类型
su.setDeniedFilesList( "jsp,asp,php,aspx,html.htm ");
//单个文件最大限制
su.setMaxFileSize(2000000);
//总共上传文件限制
su.setTotalMaxFileSize(5000000);
//开始上传,如果超过限制或者为不允许类型,抛出异常提示
su.setContentDisposition(null);
try {
su.upload();
} catch (Exception e) {
out.println( "你选择的文件不允许上传或者文件过大,请返回检查! ");
}
//得到单个上传文件的信息
for (int i = 0; i < su.getFiles().getCount(); i++) {
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if (file.isMissing())
continue;
//定义上传后另存为的文件名
String filename = String.valueOf(time.get(Calendar.YEAR))
+ String.valueOf(time.get(Calendar.MONTH))
+ String.valueOf(time.get(Calendar.DAY_OF_MONTH)+1)
+ String.valueOf(time.get(Calendar.HOUR_OF_DAY))
+ String.valueOf(time.get(Calendar.MINUTE))
+ String.valueOf(time.get(Calendar.SECOND))
+ String.valueOf(rd.nextInt(100)) + ". "
+ file.getFileExt();
//文件另存为
file.saveAs( "/UserFiles/smallImage/ " + filename);
out.println( "文件上传成功:/UserFiles/smallImage/ " + filename);
out.println( " <script> parent.document.form1.pic.value= '/UserFiles/smallImage/ "+filename+ " ' </script> ");
}
%>
是这样的不.