从网上下载一个SmartUpload的控件可以使用。

解决方案 »

  1.   

    java在网络间传递数据是采用 ISO8859-1 编码的,如果客户端不解码,中文当然是乱码了。
      

  2.   

    com.jspsmart.upload.SmartUpload控件需要下载,给分吧html 页面文件
    <html><head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <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>&Iuml;&micro;&Iacute;&sup3;&Icirc;&not;&raquo;¤</title>
    </head><script LANGUAGE="javascript">
    function my_ok() {
    var str = form1.filename.value; if (str=='')
    {
    alert("&Ccedil;&euml;&Ntilde;&iexcl;&Ocirc;&ntilde;&Ograve;&raquo;&Igrave;&otilde;&Icirc;&Auml;&frac14;&thorn;");
    form1.filename.focus(); 
    return false;
    }

    form1.submit(); }
    </script>
    <body><h1 align="center"><font color="#FF00FF">&Eacute;&Iuml;&acute;&laquo;&Icirc;&Auml;&frac14;&thorn;</font></h1>
    <hr>
    <form id=form1 ENCTYPE="multipart/form-data" action="upload.jsp" method="POST">  <table border="1" width="85%" height="57">
        <tr>
          <td width="10%" height="25">&sup2;&iquest;&nbsp; &Atilde;&Aring;</td>    
          <td width="90%" height="25"><input type="text" name="dept" size="65"></td>
        </tr>
        <tr>
          <td width="10%" height="25">&sup2;&Ugrave;×÷&Otilde;&szlig;</td>
          <td width="90%" height="25"><input type="text" name="actor" size="65"></td>
        </tr>
        <tr>
          <td width="10%" height="25">±ê&nbsp; &Igrave;&acirc;</td>    
          <td width="90%" height="25"><input type="text" name="title" size="65"></td>
        </tr>
        <tr>
          <td width="10%" height="25">&Icirc;&Auml;&frac14;&thorn;&Atilde;&ucirc;</td>
          <td width="90%" height="25"><input type="file" name="filename" size="65"></td>
        </tr>
        <tr>
          <td width="10%" height="25">&Agrave;&cedil;&nbsp; &Auml;&iquest;</td>  
          <td width="90%" height="25"><select size="1" name="item">
              <option>&Aacute;ì&micro;&frac14;&raquo;&icirc;&para;&macr;</option>
              <option>&raquo;á&Ograve;é°&sup2;&Aring;&Aring;</option>
              <option>&Iacute;¨&Ouml;&ordf;&sup1;&laquo;&cedil;&aelig;</option>
            </select></td>
        </tr>
      </table>
      <p><input type="button" value="&Igrave;á&frac12;&raquo;" name="B1" onClick="javascript:my_ok();"><input type="reset" value="&Egrave;&laquo;&sup2;&iquest;&Ouml;&Oslash;&ETH;&acute;" name="B2"></p>
    </form></body></html>JSP文件
    <%@ page contentType="text/html;charset=gb2312"%>
    <%@ page import="com.jspsmart.upload.*"%> 
    <%@ page import="database.mssql_bean"%> 
    <%@ page import="java.sql.*"%> <% SmartUpload mySmartUpload = new SmartUpload(); int count=0;

    mySmartUpload.initialize(pageContext);             //&sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;
    mySmartUpload.setTotalMaxFileSize(5000000);        //&Icirc;&Auml;&frac14;&thorn;×&icirc;&acute;ó&sup3;&szlig;&acute;&ccedil;5M  
    mySmartUpload.upload();    //&Eacute;&Iuml;&acute;&laquo;

    String filename = mySmartUpload.getFiles().getFile(0).getFileName();

    String dept = mySmartUpload.getRequest().getParameter("dept");
    String actor = mySmartUpload.getRequest().getParameter("actor");
    String title = mySmartUpload.getRequest().getParameter("title");
    String item = mySmartUpload.getRequest().getParameter("item");

        String sql = "insert into doc(item,title,time,dept,actor,filename) select (select item from itemlist where descr='"+item+"'),'"+title+"',"+"getdate(),'"+dept+"','"+actor+"','doc/"+filename+"'";
    mssql_bean mb = new mssql_bean();
        String temp = null;
        temp = mb.getconn();
    temp = mb.modify(sql);
    mb.close();

    try {    
    count = mySmartUpload.save("/upload");     //&acute;&aelig;&Aring;&Igrave;
    %>
    <script LANGUAGE="javascript">
    alert ("&Eacute;&Iuml;&acute;&laquo;&sup3;&Eacute;&sup1;&brvbar;!");
    </script>
    <%
        } 
    catch (Exception e) 
        {  
    %>
    <script LANGUAGE="javascript">
    alert ("&Eacute;&Iuml;&acute;&laquo;&Ecirc;§°&Uuml;,&Ccedil;&euml;&Ocirc;&Ugrave;&Ecirc;&Ocirc;&Ograve;&raquo;&acute;&Icirc;!");
    window.location="upload.htm";
    </script>
    <%
        } 
    %>
    <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>New Page 1</title>
    </head><script>
    function ex() {
       window.location="upload.htm"; 
    }
    </script><body><h1 align="center"><font color="#FF00FF">&Eacute;&Iuml;&acute;&laquo;&Icirc;&Auml;&frac14;&thorn;&frac12;á&sup1;&ucirc;</font></h1>
    <hr>
    <form id=form1 method="post" action="upload.htm">  <table border="1" width="85%" height="57">
        <tr>
          <td width="10%" height="25">&sup2;&iquest;&nbsp; &Atilde;&Aring;</td>    
          <td width="90%" height="25"><%=dept%></td>
        </tr>
        <tr>
          <td width="10%" height="25">&sup2;&Ugrave;×÷&Otilde;&szlig;</td>
          <td width="90%" height="25"><%=actor%></td>
        </tr>
        <tr>
          <td width="10%" height="25">±ê&nbsp; &Igrave;&acirc;</td>    
          <td width="90%" height="25"><%=title%></td>
        </tr>
        <tr>
          <td width="10%" height="25">&Icirc;&Auml;&frac14;&thorn;&Atilde;&ucirc;</td>
          <td width="90%" height="25"><%=filename%></td>
        </tr>
        <tr>
          <td width="10%" height="25">&Agrave;&cedil;&nbsp; &Auml;&iquest;</td>  
          <td width="90%" height="25"><%=item%></td>
        </tr>
      </table>
      <p align="center"><input type="submit" value="·&micro;    &raquo;&Oslash;" name="B1"></p>
    </form></body></html>
      

  3.   

    需要用到第三方的bean,我自己做了一个,要的话给发email给我,
    http://expert.csdn.net/Expert/topic/1654/1654590.xml?temp=.3409845