用jsp利用application对象,编写一个计数器页面,代码哪里错了,大神们来看啊

2025-05-23 19:23:55
推荐回答(1个)
回答1:

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>


<%
Integer count = (Integer) application.getAttribute("count");
if (count == null) {
count = new Integer(0);
}
application.setAttribute("count", ++count);
out.print("您是第");
for (char ch : count.toString().toCharArray()) {
out.println("");
}
out.print("位访客");
%>

试试这个吧,要把数字的每一位输出出来才对。