String s=new String(request.getParameter("file"));即可!!!!111

解决方案 »

  1.   

    multipart/form-data是不能用request.getParameter的.参考:<%@ 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>
      

  2.   

    enctype="multipart/form-data"同意楼上的。问题就在这里。
      

  3.   

    问题是我去掉了enctype="multipart/form-data"还是得不到URL,而且其它text类别的input
    也是不行啊。
    输入文件:
    <form action="dopicture.jsp"  method="post" name="form1">
      <br>
      <input type="text" name="a">
      <input type="file" name="file">
      <input type="submit" name="Submit" value="Submit">
    </form>
    输出文件:
    String x=(String)request.getParameter("file");
    String y=(String)request.getParameter("a");
    out.println(x);
    out.println(y);
    输出结果为:Null
                Null