在html文件中写上这一行就行了
解决方案 »
- Exception in thread "main" java.lang.NullPointerException
- 聊天信息截取
- eclipse是否可以图形化jsp页面吧
- java对象数组如何打印
- 有人了解SNMP么?有用java开发过的人么? 进来看看谢谢!
- 关于properties文件在tomcat中的配置路径问题?
- 急!!!在线等
- java中如何探测局域网中的所有主机
- 线程池问题探讨,高手请进
- 新手的问题????
- 请问各位:如何将一个日期型Date写入Access数据库的一个字段(日期/时间类型)?
- 强烈推荐:http://www.flashline.com ,难到国内就不能建个这样的平台吗?
分特,为什么打开html源文件却没有<meta...>这个东东呢?
说明request。setContentType并没有执行阿!!!
5555555555555555555555555555555555555555
我设了阿:((
// 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);
}
} ///:~ 看看这个!
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.
java内部不是unicode吗,中文表示应该没问题阿可以指点我一下吗?51649333:)