欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Enumeration cannot be resolved to a type

程序员文章站 2022-04-25 21:25:22
...
An error occurred at line: 12 in the jsp file: /index.jsp
Enumeration cannot be resolved to a type
9: <body>
10: 	<%
11: 	    out.println("Hello Word!"); 
12: 	    Enumeration headerNames = request.getHeaderNames();
13: 	    while (headerNames.hasMoreElements()) {
14: 	        String paramName = (String) headerNames.nextElement();
15: 	        out.print("<tr><td>" + paramName + "</td>\n");


Stacktrace:] with root cause
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 12 in the jsp file: /index.jsp
Enumeration cannot be resolved to a type
9: <body>
10: 	<%
11: 	    out.println("Hello Word!"); 
12: 	    Enumeration headerNames = request.getHeaderNames();
13: 	    while (headerNames.hasMoreElements()) {
14: 	        String paramName = (String) headerNames.nextElement();
15: 	        out.print("<tr><td>" + paramName + "</td>\n");


Stacktrace:
	at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
	at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
	at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
	at org.apache.jasper.compiler.Compiler.__compile(Compiler.java:378)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
	at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:390)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

解决方案:jsp页面需要引入:

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

   

 

相关标签: jsp