jsp----
<form name="frmAttrDictAdd" method="post"  action="nastypecontroller?actioncode=<%=ActionCode.NASTYPE_ADD%>" class="for1">
  <table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
    <tr align="center">
      <td width="24%" height=25 class="topbg">NAS_TYPE_CODE
      <td width="76%" class="tdbg"> <div align="left">
          <input type="text" name="textfield1">
        </div>
    <tr>
      <td height=23 align="center"  class="topbg">NAS_TYPE_NAME</td>
      <td align="center"  class="tdbg"><div align="left">
          <input type="text" name="textfield2">
        </div></td>
    </tr>
    </tr>
     <tr>
      <td height=23 align="center"  class="topbg">VARLIST</td>
      <td align="center"  class="tdbg"><div align="left">
          <input type="text" name="textfield3">
        </div></td>
    </tr>
  </table>
</form>

解决方案 »

  1.   

    servlet---
     String nasTypeNo = request.getParameter("textfield1");
          String nasTypeName = request.getParameter( "textfield2");
          String varlist = request.getParameter "textfield3");
          NasTypeModel nasType = new NasTypeModel();
          nasType.setNasTypeCode(nasTypeNo);
          nasType.setNasTypeName(nasTypeName); ????请问这里如何处理  NasTypeModel的varlist字段为Blob类型
      
    //      nasType.setVarlist((Blob)(varlist));
          _nasTypeDelegate.add(nasType);
          list_web(request, response);
      

  2.   

    String mysql="INSERT INTO NAS_TYPE ( NAS_TYPE_CODE , NAS_TYPE_NAME , VARLIST ) VALUES (? , ?, ? )";
    opst=(oracle.jdbc.driver.OraclePreparedStatement)db1.conn.prepareStatement(mysql);
    opst.setString(1,nasType.getNasTypeCode);
    opst.setString (2,nasType.getNasTypeCode);????请问这里可以这样处理么
    opst.setBlob (3,nasType.getVarlist);
    opst.executeUpdate();
    opst.clearParameters();
      

  3.   

    给个例子你。
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class BlobColumn 
    {
    public static void main(String[] args) 
    {
    String driver = "org.gjt.mm.mysql.Driver";
    String url = "jdbc:mysql://localhost:3306/test";
    String user = "root";
            String password = "roger";
    Vector stream=null;
    stream=new Vector();
            try
    {
    Class.forName(driver);
            }
    catch(ClassNotFoundException e) 
    {
    System.out.println("ClassNotFoundException ->"+e);
            }
    try
    {
                Connection conn = DriverManager.getConnection(url, user, password);
    PreparedStatement pstmt = conn.prepareStatement("INSERT INTO  star VALUES(?,?,?)");
    try
    {
    //String path="D:\\book\\photo\\";
    String path="D:\\pictrue\\美女精华\\";
    File d=new File(path);//建立当前目录中文件的File对象
    File list[]=d.listFiles();//取得代表目录中所有文件的File对象数组
    for(int i=0;i<list.length;i++)
    {
    if(list[i].isFile())
    {
    String FileName=list[i].getName();
    InputStream fin = new FileInputStream(path+FileName);
    int length = (int) fin.available();
    System.out.println("FileName ->"+FileName+"     Size ->"+length);
    stream.add(fin);
    pstmt.setString(1,FileName);
    pstmt.setDouble(2,length);
                    pstmt.setBinaryStream (3,fin,length);
    pstmt.addBatch();
    }
    }
    }
    catch (Exception e)
    {
    System.out.println("IOException ->"+e);
    }
    int[] res=pstmt.executeBatch();
               // pstmt.clearParameters();
                pstmt.close();
    for (int i=0;i<stream.size();i++)
    {
    try
    {
    InputStream in=(InputStream)stream.get(i);
    in.close();
    }
    catch (Exception e)
    {
    System.out.println("close exception ->"+e);
    }
    }
             /*   fin.close();
                // 從資料庫取出檔案  
    Statement stmt = conn.createStatement();
                ResultSet result = stmt.executeQuery("SELECT * FROM picture");
                result.next();
                String description = result.getString(1);
                Blob blob = result.getBlob(2);
    System.out.println("blob length ->"+(int)blob.length());
                // 寫入檔案           
    System.out.println("檔案描述:" + description);
                FileOutputStream fout = new FileOutputStream("girl_2.jpg");
    fout.write(blob.getBytes(1, (int)blob.length()));
                fout.flush();
                fout.close();    */       
               // conn.close();
    }
    catch(Exception e) 
    {  
    System.out.println("SQLException ->"+e);
            }   
    }
    }