1.直接上类代码:import javax.servlet.http.*;public class listenTest implements HttpSessionListener{public static int count; --此处定义了静态变量public listenTest() {super();// TODO Auto-generated cons;tructor stubcount=0;}....2.在网页中引用的格式:<%=listenTest.count %> 3.在运行网页进行测试时的错误:An error occurred at line: 113 in the jsp file: /index.jsplistenTest cannot be resolved to a variable110: 111: <%/**涓嬮溃涓鸿〃鍗曞强鍙傛暟銆佽烦杞祴璇�/ %>112: <% out.print("--------------------------琛ㄥ崟娴嬭瘯 -----------------------------------------"); %>113: <%=listenTest.count %> 114: 115: 116: <form name="form1" action="x.ao" method="post"><br>
2 回答
繁花不似锦
TA贡献1851条经验 获得超4个赞
要实现JSP静态属性在网页中显示,应考虑对象和静态函数两种情况,具体如下:
1、对象。参照jsp:bean的用法,配合使用jsp:getProperty即可。
2、静态的函数。在
<%@ page language="java" import="java.util.*,com.rh.entity.*" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
import="java.util.*,com.rh.entity.*" 加上这句,保证Infomation 类的全路径,即可在jsp中使用
<%=Infomation.getJavaRuntimeVersion() %>
综上,JSP静态属性即可显示在网页中.
添加回答
举报
0/150
提交
取消
