<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage=""%> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>声明示例</title> </head> <%! //声明一个变量 public int count = 0; //声明一个方法 public String info(){ return "hello"; } %> <body> <% out.println(count++); %> <br /> <% out.println(info()); %> </body> </html>