你debug看过吗?是不是你在DB中定义的数据类型有问题,在DB更新时出了问题。我是猜的,你试一下

解决方案 »

  1.   

    还有,apache是限制最大上传文件大小的,看看是不是由于apache设置引起的
      

  2.   

    我在本地tomcat下运行可以传500多M 没问题,可部署到远程服务器上传4M就有问题,不知道是网络问题还是tomcat问题???
    我在struts-config.xml中加了<controller maxFileSize="600M" />
      

  3.   

    是不是win2003啊,win2003会有上穿文件限制
      

  4.   

    利用newxy你可以用标签控制文件大小,且看用写java代码。看了你的提问,我特意试了大于4M的文件上传,很正常。可以参看范例 http://www.newxy.net/zh_cn/samples/index.jsp
    newxy(新座标)技术网站 http://www.newxy.net假设session中有一名为fileBean的java bean,其中有一属性title是资源名,资源名最好有文件类型后缀,一属性content是文件内容。 设数据库中有一表downCount用于下载记数,有一主关键字,为数据类型如整型,或字符串型,另有一字段保存下载的资源名,这字段为 resName varchar(255) not null,而且必须要有名为resName这个字段。在web.xml中申明net.newxy.servlet.Download。  <servlet>
        <servlet-name>download</servlet-name>
        <servlet-class>net.newxy.servlet.Download</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>download</servlet-name>
        <url-pattern>/download</url-pattern>
      </servlet-mapping>
    建立下载链接:<html:link target="_blank" page="/download?table=downCount&name=fileBean&property=content&fileName=title">下载</html:link>显示下载记数:<nbean:formBean name="downCounts" refresh="true" sql="select resName,count(*) as counts from downCount group by resName order by resName"/>
    <logic:notEmpty name="downCounts" property="_coll">
      <table border="1">
        <caption>下载计数</caption>
        <tr>
          <td>资源名</td><td>下载次数</td>
        </tr>
        <logic:iterate id="rec" name="downCounts" property="_coll">
          <tr>
            <td><bean:write name="rec" property="resName"/></td>
            <td align="center"><bean:write name="rec" property="counts" /></td>
          </tr>
        </logic:iterate>
      </table>
    </logic:notEmpty>
      

  5.   

    1.add.jsp
    <html:form action="/idvHelps" method="post" onsubmit="javascript:onSubmit();" enctype="multipart/form-data">
    <html:file property="file"/>
    </html:form>
      

  6.   

    2.IdvHelpsForm
    package com.yjedu.idv.web.form;import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionMapping;
    import com.yjedu.base.BaseForm;
    import org.apache.struts.upload.FormFile;public class IdvHelpsForm extends BaseForm {
    private String helpCode;
    private String helpName;
    private String helpUrl;
            private FormFile file; public String getHelpCode() {return helpCode;}
    public void setHelpCode(String helpCode) {this.helpCode = helpCode;} public String getHelpName() {return helpName;}
    public void setHelpName(String helpName) {this.helpName = helpName;} public String getHelpUrl() {return helpUrl;}
    public void setHelpUrl(String helpUrl) {this.helpUrl = helpUrl;}        public FormFile getFile() {return file;}
    public void setFile(FormFile file) {this.file = file;} public void reset(ActionMapping mapping, HttpServletRequest request) {
            helpCode = null;
            helpName = null;
            helpUrl = null;
            file = null;
        }
    }
      

  7.   

    struts上传文件默认值好象是2M,你可以修改ActionServlet的设置参数。但我强烈推荐使用newxy技术,可以不写java代码。http://www.newxy.net
      

  8.   

    3.IdvHelpsAction
    package com.yjedu.idv.web.action;import java.io.*;
    import java.util.*;import javax.servlet.http.*;import com.yjedu.base.*;
    import com.yjedu.idv.data.vo.*;
    import com.yjedu.idv.service.*;
    import com.yjedu.idv.web.form.*;
    import com.yjedu.util.*;
    import org.apache.struts.action.*;
    import org.apache.struts.upload.*;/**
     * 使用帮助Action
     */
    public class IdvHelpsAction extends BaseDispatchAction {
       public ActionForward save(ActionMapping mapping, ActionForm form,
                                  HttpServletRequest request,
                                  HttpServletResponse response) throws Exception {        IdvHelpsForm idvHelpsForm = (IdvHelpsForm) form;        IdvHelps idvHelps = new IdvHelps();        idvHelps.setHelpCode(idvHelpsForm.getHelpCode());
            idvHelps.setHelpName(idvHelpsForm.getHelpName());
            idvHelps.setHelpUrl(idvHelpsForm.getHelpUrl());
            //上传文件
            FormFile file = idvHelpsForm.getFile();
            if (!file.getFileName().equals("")) {
                String fileName = file.getFileName();
                String extName = "";
                if (fileName.lastIndexOf(".") > 0) {
                    extName = fileName.substring(fileName.lastIndexOf("."));
                }
                File f = new File(StringUtil.replace(getServlet().
                                                     getServletContext().
                                                     getRealPath("/doc/helps/"),
                                                     "\\", "/"));
                if (!f.isDirectory()) {
                    f.mkdirs();
                }
                String relpath = "/doc/helps/" + DateUtils.getTimeStamp() + extName;
                String abspath = getServlet().getServletContext().getRealPath(
                        relpath);
                abspath = StringUtil.replace(abspath, "\\", "/");
                idvHelps.setHelpUrl(relpath);
                InputStream stream = file.getInputStream();
                OutputStream bos = new FileOutputStream(abspath);
                int bytesRead = 0;
                byte[] buffer = new byte[8192];
                while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
                    bos.write(buffer, 0, bytesRead);
                }
                bos.close();
            }
         }
    }
      

  9.   

    4.struts-config.xml
    <struts-config>
    ....
    <controller maxFileSize="600M" />
    </struts-config>
      

  10.   

    5.服务器sun机器(出现上述问题)
    本机windows xp(无问题)