在html文件中写上这一行就行了

解决方案 »

  1.   

    我就是已经写了:response.setContentType("text/html; charset=gb2312");阿!!!!!
    分特,为什么打开html源文件却没有<meta...>这个东东呢?
    说明request。setContentType并没有执行阿!!!
    5555555555555555555555555555555555555555
      

  2.   

    to poppy2001:怎么在servlet中进行设置??
      

  3.   

    不就是response.setContentType吗??
    我设了阿:((
      

  4.   

    //: EncodeDemo.java
    // Demonstration of URLEncoder.encode()
    import java.net.*;public class EncodeDemo {
      public static void main(String[] args) {
        String s = "";
        for(int i = 0; i < args.length; i++)
          s += args[i] + " ";
        s = URLEncoder.encode(s.trim());
        System.out.println(s);
      }
    } ///:~ 看看这个!
      

  5.   


        nm = decodeURLString(name);
        
    Encoding data for CGI 
    In this version, the name and the email address will be collected and stored in the file in the form: First Last <[email protected]>; 
    This is a convenient form for many mailers. Since two fields are being collected, there are no shortcuts because CGI has a particular format for encoding the data in fields. You can see this for yourself if you make an ordinary HTML page and add the lines: <Form method="GET" ACTION="/cgi-bin/Listmgr2.exe">
    <P>Name: <INPUT TYPE = "text" NAME = "name" 
    VALUE = "" size = "40"></p>
    <P>Email Address: <INPUT TYPE = "text" 
    NAME = "email" VALUE = "" size = "40"></p>
    <p><input type = "submit" name = "submit" > </p>
    </Form>This creates two data entry fields called name and email, along with a submit button that collects the data and sends it to a CGI program. Listmgr2.exe is the name of the executable program that resides in the directory that’s typically called “cgi-bin” on your Web server. [65] (If the named program is not in the cgi-bin directory, you won’t see any results.) If you fill out this form and press the “submit” button, you will see in the URL address window of the browser something like: http://www.myhome.com/cgi-bin/Listmgr2.exe?
    name=First+Last&[email protected]&submit=Submit(Without the line break, of course). Here you see a little bit of the way that data is encoded to send to CGI. For one thing, spaces are not allowed (since spaces typically separate command-line arguments). Spaces are replaced by ‘ +’ signs. In addition, each field contains the field name (which is determined by the HTML page) followed by an ‘ =’ and the field data, and terminated by a ‘ &’.At this point, you might wonder about the ‘ +’, ‘ =,’ and ‘ &’. What if those are used in the field, as in “John & Marsha Smith”? This is encoded to: John+%26+Marsha+Smith
    That is, the special character is turned into a ‘%’ followed by its ASCII value in hex. Fortunately, Java has a tool to perform this encoding for you. It’s a static method of the class URLEncoder called encode( ). You can experiment with this method using the following program: //: EncodeDemo.java
    // Demonstration of URLEncoder.encode()
    import java.net.*;public class EncodeDemo {
      public static void main(String[] args) {
        String s = "";
        for(int i = 0; i < args.length; i++)
          s += args[i] + " ";
        s = URLEncoder.encode(s.trim());
        System.out.println(s);
      }
    } ///:~ This takes the command-line arguments and combines them into a string of words separated by spaces (the final space is removed using String.trim( )). These are then encoded and printed. To invoke a CGI program, all the applet needs to do is collect the data from its fields (or wherever it needs to collect the data from), URL-encode each piece of data, and then assemble it into a single string, placing the name of each field followed by an ‘ =’, followed by the data, followed by an ‘ &’. To form the entire CGI command, this string is placed after the URL of the CGI program and a ‘ ?’. That’s all it takes to invoke any CGI program, and as you’ll see you can easily do it within an applet. 
      

  6.   

    to风雨飞扬:你是说我应该自己做编码的工作吗?jdk1。4和jb5不会这么土吧???
    java内部不是unicode吗,中文表示应该没问题阿可以指点我一下吗?51649333:)