HTTP 状态 500 - 无法使用 Date 方法在 Eclipse 中为 JSP 编译类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19590351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:16:49  来源:igfitidea点击:

HTTP Status 500 - Unable to compile class for JSP in Eclipse with the Date method

eclipsejsptomcat

提问by user1805

I'm using Eclipse Kepler. I keep getting an error message with this code in a .jsp:

我正在使用 Eclipse 开普勒。我在 .jsp 中不断收到此代码的错误消息:

HTTP Status 500 - Unable to compile class for JSP:

HTTP 状态 500 - 无法为 JSP 编译类:



type Exception report

输入异常报告

message Unable to compile class for JSP:

消息无法为 JSP 编译类:

description The server encountered an internal error that prevented it from fulfilling this request.

说明 服务器遇到内部错误,无法完成此请求。

exception

例外

org.apache.jasper.JasperException: Unable to compile class for JSP:

org.apache.jasper.JasperException:无法为 JSP 编译类:

An error occurred at line: 13 in the jsp file: /index.jsp Syntax error on token "import", delete this token 10: 11: 12: 13: <% page import ="java.util.Date" %> 14: 15: <%= new Date () %> 16:

在 jsp 文件中的第 13 行发生错误:/index.jsp 标记“导入”的语法错误,删除此标记 10:11:12:13:<% page import ="java.util.Date" %> 14 : 15: <%= 新日期 () %> 16:

An error occurred at line: 13 in the jsp file: /index.jsp Syntax error, insert ";" to complete Statement 10: 11: 12: 13: <% page import ="java.util.Date" %> 14: 15: <%= new Date () %> 16:

在 jsp 文件中的第 13 行发生错误:/index.jsp 语法错误,插入“;” 完成语句10:11:12:13:<%page import="java.util.Date"%>14:15:<%=newDate()%>16:

An error occurred at line: 15 in the jsp file: /index.jsp Date cannot be resolved to a type 12: 13: <% page import ="java.util.Date" %> 14: 15: <%= new Date () %> 16: 17: 18:

jsp 文件中第 15 行出现错误:/index.jsp 日期无法解析为类型 12: 13: <% page import ="java.util.Date" %> 14: 15: <%= new Date ()%>16:17:18:

Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

堆栈跟踪:org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366) org.apache.jasper.compiler.JDTCompiler.generateClass( JDTCompiler.java:468) org.apache.jasper.compiler.Compiler.compile(Compiler.java:378) org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) org.apache.jasper.compiler。 Compiler.compile(Compiler.java:340) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper. servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.42 logs.

注意 Apache Tomcat/7.0.42 日志中提供了根本原因的完整堆栈跟踪。



Apache Tomcat/7.0.42

Apache Tomcat/7.0.42

There is the code:

有代码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>



<% page import ="java.util.Date" %>

<%= new Date () %>

</body>
</html> 

Thank you

谢谢

回答by Zyga

Its a wrong syntax, you are missing "@".

它的语法错误,您缺少“@”。