利用SMARTUPLOAD组件无法获得参数?

zcwm 2003-04-21 05:38:10
我用smartupload组件进行上传,把form的传递方式设置为ENCTYPE="multipart/form-data",在servlet中,先初始化smartupload,用smartupload提供的getRequest()方法获得Request,然后再用获得的request的getParameter()获得参数,但是总是null,那位能帮忙解决一下?
...全文
44 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
hanty 2003-04-21
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="inewBean" scope="page" class="news.inewBean" />
<HTML>
<BODY BGCOLOR="white">
<H1>jspSmartUpload : Sample 3</H1>
<HR>
<%

// Variables
int count=0;
// Initialization
mySmartUpload.initialize(pageContext);
// Only allow txt or htm files
//mySmartUpload.setAllowedFilesList("htm,html,txt,,");
// DeniedFilesList can also be used :
// mySmartUpload.setDeniedFilesList("exe,bat,jsp");
// Deny physical path
// mySmartUpload.setDenyPhysicalPath(true);
// Only allow files smaller than 50000 bytes
// mySmartUpload.setMaxFileSize(50000);
// Deny upload if the total fila size is greater than 200000 bytes
// mySmartUpload.setTotalMaxFileSize(200000);
// Upload
mySmartUpload.upload();
// Save the files with their original names in a virtual path of the web server
try {
count = mySmartUpload.save("/pic/upload/news", mySmartUpload.SAVE_VIRTUAL);
String title=mySmartUpload.getRequest().getParameter("title");
String content=mySmartUpload.getRequest().getParameter("content");
String picture=mySmartUpload.getFiles().getFile(0).getFileName();

inewBean.insert_news(title,content,picture);
} catch (Exception e){
out.println("<b>Wrong selection : </b>" + e.toString());
}
// Display the number of files uploaded
out.println(count + " file(s) uploaded.");

%>
</BODY>
</HTML>
回复
lilehao 2003-04-21
smartupload提供的getRequest()方法获得Request不是jsp中的request,而是smartupload包中的一个java类,用来存储页面中提交的request变量,因此你必须将Request.class也放到smartupload.class 所在的目录
回复
d80 2003-04-21
这样吧
String delPicId=mySmartUpload.getRequest().getParameter("delPicId");
回复
x_coolboy 2003-04-21
你想得到什么参数?smartupload不需要什么参数吧?
这是我的代码片段,已投入商业运行的:
JSP1:
<FORM name=addattach action="" method=post encType=multipart/form-data align="left">
<INPUT class=form02 type=file name=attachfile>

JSP2:
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />

mySmartUpload.initialize(pageContext);
//mySmartUpload.setTotalMaxFileSize(100000);
mySmartUpload.upload();

count = mySmartUpload.save(“随便起的文件名”);
回复
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-04-21 05:38
社区公告
暂无公告