jsp 中的this 表示的是当前的 pageContext 对象 ,而该对象可以获取其它八个内置对象,当前也包括ServletContext对象;但是为什么我这里显示没有该方法呢?
其它:我这里是用
下面附上 jsp代码
<%@ page import="java.util.Set" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="Listener.OnlineUserList" %>
<%--
Created by IntelliJ IDEA.
User: wyq19
Date: 2019/8/30
Time: 17:36
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h2>在线用户列表</h2>
<%
Set all = (Set)this.getServletContext().getAttribute("online");
Iterator iter = all.iterator();
while (iter.hasNext()){
%>
<%= iter.next()%>、
<%
}
%>
</body>
</html>