<%@ page contentType = "text/html;charset=GB2312" %>
<%@ page import = "java.util.*" %><html>
<head>
</head>
<body>
<%
String s = pageContext.getServletContext().getServletInfo();
//String s = application.getServletInfo();
%>
</body>
</html>为什么会报错说
An error occurred at line: 9 in the jsp file: /home.jsp
The method getServletInfo() is undefined for the type ServletContext
6: </head>
7: <body>
8: <%
9: String s = pageContext.getServletContext().getServletInfo();
10: //String s = application.getServletInfo();
11: %>
12: </body>
怎么会未定义......求解(包括被注释掉的方法也不行......)
<%@ page import = "java.util.*" %><html>
<head>
</head>
<body>
<%
String s = pageContext.getServletContext().getServletInfo();
//String s = application.getServletInfo();
%>
</body>
</html>为什么会报错说
An error occurred at line: 9 in the jsp file: /home.jsp
The method getServletInfo() is undefined for the type ServletContext
6: </head>
7: <body>
8: <%
9: String s = pageContext.getServletContext().getServletInfo();
10: //String s = application.getServletInfo();
11: %>
12: </body>
怎么会未定义......求解(包括被注释掉的方法也不行......)
javax.servlet.ServletContext 把这两个包引入进来试试。
<%@ page contentType = "text/html;charset=GB2312"%>
<%@ page import = "javax.servlet.jsp.PageContext" %>
<%@ page import = "javax.servlet.ServletContext" %><html>
<head>
</head>
<body>
<%
String s = pageContext.getServletContext().getServletInfo();
%>
</body>
</html>
依旧报错
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 10 in the jsp file: /get.jsp
The method getServletInfo() is undefined for the type ServletContext
7: </head>
8: <body>
9: <%
10: String s = pageContext.getServletContext().getServletInfo();
11: %>
12: </body>
13: </html>
依旧说未定义.......
多看看API public abstract class javax.servlet.jsp.PageContext
pageContext里的p是不是应该大写呀?
javax.servlet.Servlet中才有不过也无须import这些类,在jsp中根本就没用到。这样用试试:
<html>
<body>
<%= page.getServletInfo() %>
</body>
</html>