<%@ page contentType="text/html;charset=UTF-8"%> <!-- 字符编码为utf-8,不然会乱码。。。。 --> <%@ page import="java.util.Date"%> <%!Date date; public int continueSum(int start, int end) { int sum = 0; for (int i = start; i <= end; i++) sum += i; return sum; }%> <html> <head> <title>first blood</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- head中间要加这句话,不然会乱码 --> </head> <body> <font size=4><p> 程序片创建Date对象: <% date = new Date(); out.println("<BR>" + date); int start = 1; int end = 100; int sum = continueSum(start, end); %> <br>从 <%=start%> 至 <%=end%> 的连续和是 <%=sum%></font> </body> </html>
<%@ page contentType="text/html;charset=gb2312"%> <html> <head> <title>first blood</title> </head> <body bgcolor=yellow> <font size=3> <%!int i = 0;%> <% i++; %> <p> 您是第 <%=i%> 个访问本站的用户. </body> </html>
时间: 2024-10-12 20:23:12