问题:如何得到request.getParameter("tttent"); 的值。这样是得不到的。试一下smartupload里的方法

解决方案 »

  1.   

    我不想用这个组件,关于上传我已经达到目的,关键是:在htm中的Form中如果存在文本框的话,
            在jsp中的不到文本框内容。
    如果去掉
     enctype="multipart/form-data" 
    则这样
    request.getParameter("tttent"); 
    是可以的到内容的。
      

  2.   

    既然是上传,你试试这个jspSmartUpload.jspSmartUpload 在上传中可以用getParameter("tttent"); 得到传递的其他参数,这个我是用过的!jspSmartUpload上传下载全攻略http://www.tongyi.net/article/20031015/200310153755.shtml有详细的使用,包含getParameter("tttent");  方法!
      

  3.   

    如果你用tomcat5以下的版本,
     byte[] db=new byte[request.getContentLength()];
        DataInputStream in=new DataInputStream(request.getInputStream());
        in.read(db);
        in.close();
        System.out.println(new String(db));
    看一下吧。请求流的内容你要自己解决吗?还是用smartupload吧。
      

  4.   

    那个multipart/form-data
    不能去掉,这里取得那个直不能用request.getParameter("")来取得。
    你的上传bean里面有响应的方法。你可以查询哈
      

  5.   

    自己做一下:
    <%@ page contentType="text/html; charset=gb2312"%>
    <%@ include file="/DataIni/DataOpen.jsp"%>
    <%@ include file="/ScriptLib/Init.jsp"%>
    <%
    InputStream InData=null;
    int iSize,iLength;
    iLength=request.getContentLength();
    byte[] Buffer=new byte[iLength];
    byte[] Byte_File;
    if(iLength>0)
    {
    InData=request.getInputStream();
    String ContentType=request.getContentType();
    iSize=InData.read(Buffer);
    if(iSize!=-1)
    {
    //数据处理开始
    String FileData=new String(Buffer,"ISO8859-1");
    //
    //正则字串:"name=\"";
    //正则字串:"filename=\"";

    String strSplit=ContentType.substring(ContentType.lastIndexOf("=")+1,ContentType.length());
    String strSub[]=FileData.split(strSplit);
    String strElement;
    int iBegin,iEnd;
    iBegin=0;iEnd=0;
    String FieldName,FieldValue;
    int bTrue;
    bTrue=0;
    int iPos;
    iPos=0;
    int iLocation;
    iLocation=0;
    for(int iIndex=0;iIndex<strSub.length;iIndex++)
    {
    strElement=strSub[iIndex];
    iBegin=strElement.indexOf("name=\"",0);
    if(iBegin!=-1)
    {
    iEnd=strElement.indexOf("\"",iBegin+6);
    FieldName=strElement.substring(iBegin+6,iEnd);
    iBegin=strElement.indexOf("filename=\"",0);
    if(iBegin!=-1)
    {
    bTrue=1;
    }
    //
    iEnd=strElement.indexOf("\r\n\r\n",0);
    if(bTrue==1)
    {
    iLocation=0;
    iPos=FileData.indexOf("filename=\"",iPos);
    iPos=FileData.indexOf("\r\n",iPos)+2;
    iLocation=FileData.indexOf(strSplit,iPos)-2;
    FieldValue=FileData.substring(iPos,iLocation);
    //FieldValue=FieldValue.replace('\255','\0');
    FieldValue=FieldValue.replaceAll("DigitalTitan","\0");
    Byte_File=FieldValue.getBytes("ISO8859-1");
    /*
    byte[] Byte_File_=FieldValue.getBytes();
    Byte_File=new byte[Byte_File_.length];
    for(int kIndex=0;kIndex<Byte_File_.length;kIndex++)
    {
    Byte_File[kIndex]=Buffer[iPos+0+kIndex];
    }
    */
    session.putValue(FieldName,Byte_File);
    }
    else
    {
    FieldValue=strElement.substring(iEnd+4);
    session.putValue(FieldName,FieldValue.substring(0,FieldValue.indexOf("\r\n")));
    }
    bTrue=0;
    }
    }
    //数据处理结束
    String Author,History;
    /*
    if((String)session.getValue("UserId")==null)
    {Author="Anonymous";}
    else
    {Author=(String)session.getValue("UserId");}
    */
    Author="Anonymous";
    java.util.Date m_Date=new java.util.Date(System.currentTimeMillis());
    History=m_Date.toString();

    boolean bDefault;
    int iC;
    oracle.sql.BLOB m_Blob;
    bDefault=odbcConn.getAutoCommit();
    odbcConn.setAutoCommit(false);
    odbcStmt.executeUpdate("insert into Project_Design(ID,Category,Subject,Body,Author,History) values(IDSERIAL.nextval,'"+(String)session.getValue("Category")+"','"+(String)session.getValue("Subject")+"',EMPTY_BLOB(),'"+Author+"','"+History+"')");
    odbcQuery="select * from Project_Design order by ID asc";
    odbcRs=odbcStmt___.executeQuery(odbcQuery);
    odbcRs.last();
    String iID=String.valueOf((int)odbcRs.getInt("ID"));
    odbcQuery="select Body from Project_Design where ID="+iID+" for Update";
    odbcRs=odbcStmt___.executeQuery(odbcQuery);
    if(odbcRs.next())
    {
    m_Blob=(oracle.sql.BLOB)odbcRs.getBlob("Body");
    BufferedOutputStream pOut=new BufferedOutputStream(m_Blob.getBinaryOutputStream());
    ByteArrayInputStream pIn=new ByteArrayInputStream((byte[])session.getValue("FieldName"));
    while((iC=pIn.read())!=-1)
    {pOut.write(iC);}
    pIn.close();
    pOut.close();
    }
    odbcConn.commit();
    odbcConn.setAutoCommit(bDefault);
    /*
    odbcQuery="select * from Project_BaseInfo where well_no='"+(String)session.getValue("WellNo")+"'";
    String bStatus;
    bStatus="false";
    odbcRs=odbcStmt.executeQuery(odbcQuery);
    if(odbcRs.next())
    {
    bStatus="true";
    }
    odbcRs.close();
    if(bStatus=="true")
    {
    String Base_Data[]=(String)session.getValue("WellNo").split(",");
    for(int oIndex=0;oIndex<Base_Data.length;oIndex++)
    {
    System.out.println(Base_Data[oIndex]);
    }
    //odbcStmt.executeUpdate("insert into Project_BaseInfo(ID,WHERE_POSITION,CREATE_POSITION,WELL_TYPE,WELL_LENGTH,WELL_DEPH_BY_DIG,WELL_DEPTH_BY_HAND,DATE_DIG,DATA_WELL,MAX_SIZE,WELL_NO) values(IDSERIAL.nextval,'"+(String)session.getValue("WellNo")+"')");
    }
    */
    System.out.println("->->->->->->->");
    //response.sendRedirect("/System/Project_Design/List.jsp");
    }
    }
    %>
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css">
    </head><body onload="//window.alert('添加成功,请返回确认浏览!');//window.location.href='/System/Project_Design/List.jsp';">
    <%@ include file="/TemplateLib/Head.jsp"%>
    <%@ include file="/TemplateLib/Tail.jsp"%>
    <%@ include file="/DataIni/DataClose.jsp"%>
    </body></html>
      

  6.   

    multipart/form-data不能用request.getParameter("")来获取参数,服务器收到的是二进制流,需要你自己处理.如上.
      

  7.   

    to  seaman0916(沙漠孤鹰) :jspSmartUpload下载不到。(google)to  gks_cn(981530):
    如你所云,multipart/FORM-DATE能够传送文件用的,我也知道的,我想了一个方案,就是在htm中同时出发两个表单,同时发送到一个jsp
    但是我不知道怎样作,我查了些资料,如下:
    <iframe id="a" ...></iframe> //form1
    <iframe id="b" ...></iframe> //form2
    <input type="button" onclick="submit()">
    ------------------------------------------------
    <script>
    function submit(){
    frames.a.document.body.form1.submit();
    frames.b.document.body.form2.submit();
    }
    </script>
    但是我不明白,具体的方案,谁能解读。或者诠释成一个页面。
      

  8.   

    我的最终页面:产品名称:  Text
    单价    :  Text
    预览图片:  File
          上传(Submit)