Java获取Html变量的值

类别:Java 点击:0 评论:0 推荐:

Author:  Tansf

代码如下
//------getParameter.java
import java.awt.*;
import java.applet.*;
public class getParameter extends Applet{
    private String title;
    public void paint(Graphics g){
 title=getParameter("title");
    g.drawString ("Hello World!",20,20);
 g.drawString ("getParameter: "+title,20,50);
 }   
}

//----------getParameter.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>tansf</title>
</head>

<body>
<applet code="getParameter.class" width="210" height="118">
<param name="title" value="tansf">
</applet>
</body>
</html>

以上代码从htm文件中获取title的值

本文地址:http://com.8s8s.com/it/it13348.htm