日期:2014-05-18  浏览次数:20769 次

使用jspsmartupload实现上传文件中的一个问题
我开始用   Tomcat   5.0.28作为服务,然后使用jspsmartupload来实现文件的上传,开始设置测试成功.但是重新启动服务器后就出问题了,换用Tomcat5.5.20后也是不行.请高手给看一下.

我的负责接收上传的文件jsp   代码是:
<%@   page   import   = "com.jspsmart.upload.SmartUpload,java.util.*,java.io.* "   %>
<%
int   count=0;
SmartUpload   su   =   new   SmartUpload();
su.initialize(pageContext);
su.upload();
try{
int   count=su.save( "/upload/ ");
if   (count==1)   {out.print( "sucess ");}
else   out.print( "Failed ");
}
catch(Exception   e)
{
out.println(e.toString());
}
out.print( "size: "+su.getSize());
%>

日志错误为:
2007-2-4   17:43:25   org.apache.catalina.core.ApplicationContext   log
淇℃伅:   ContextListener:   contextInitialized()
2007-2-4   17:43:25   org.apache.catalina.core.ApplicationContext   log
淇℃伅:   SessionListener:   contextInitialized()
2007-2-4   17:43:25   org.apache.catalina.core.ApplicationContext   log
淇℃伅:   org.apache.webapp.balancer.BalancerFilter:   init():   ruleChain:   [org.apache.webapp.balancer.RuleChain:   [org.apache.webapp.balancer.rules.URLStringMatchRule:   Target   string:   News   /   Redirect   URL:   http://www.cnn.com],   [org.apache.webapp.balancer.rules.RequestParameterRule:   Target   param   name:   paramName   /   Target   param   value:   paramValue   /   Redirect   URL:   http://www.yahoo.com],   [org.apache.webapp.balancer.rules.AcceptEverythingRule:   Redirect   URL:   http://jakarta.apache.org]]

不知道有人遇到过同样的问题吗?
谢谢   .

------解决方案--------------------
建议你改用uploadbean,上载到本地目录没有问题,而且支持中文表单提交。
<%@ page contentType= "text/html;charset=gb2312 " %>
<head>
<title> fbysss UploadBean 示例 </title>

</head>
<form name= "form1 " METHOD= "POST " ACTION= "3.jsp " ENCTYPE= "multipart/form-data ">
<input name= "title " type= "text " value= "中文字 ">
<td class= "bodystyle "> 附件 </td>
<td class= "bodystyle ">
<input name= "attach " type= "FILE " id= "attach " size= "50 " > </td>
<input name= "ok " type= "submit " value= "提交 ">
</form>

调用uploadbean
<!--
//==========================================================================
//文件:UploadBean上传实例
//功能:解决中文乱码,完成文件上传,并提供上传改名解决方案
//作者:fbysss
//msn:jameslastchina@hotmail.com
//==========================================================================
-->
<%@ page contentType= "text/html;charset=GBK " %>
<%@ page language= "java " import= "com.jspsmart.upload.* "%>
<%@ page import= "java.text.SimpleDateFormat "%>
<%@ page import= "java.io.File "%>
<%@ page import= "java.util.* "%>
<%@ page import= "javazoom.upload.* "%>
<%@ page import= "uploadutilities.FileMover "%>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
<%
request.se