错误为
严重:路径为[/HelloWorld]的上下文中servlet[jsp]的servlet.service()引发异常[无法为jsp编译类:
在生成的Java文件[f:\Java EE project.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\catalina\localhost\helloworld\org\apache\jsp\game_jsp.]第[28]行出现错误,令牌“import”语法错误,该令牌后面需要名称
StackTrace:]根本原因为org.apache.jasper.JasperException:无法为JSP编译类:
在生成的Java文件[f:\Java EE project.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\catalina\localhost\helloworld\org\apache\jsp\game_jsp.]第[28]行出现错误,令牌“import”语法错误,该令牌后面需要名称
堆栈跟踪:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:389)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:501)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
我的代码是(newfile.jsp):
null
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<!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>
<h1>Hii i am sumit. (Welcome to JSP)</h1>
<form name="myform" action="game.jsp" method="post" enctype="multipart/form-data">
Specify your name:<br />
<input type="text" name="name" size="15"/><br />
Specify your Image:<br />
Specify your File:<br />
<input type="submit" name="Submit" value="Submit your files"/>
</form>
</body>
</html>
null
(game.jsp):
null
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.util.*"%>
<%@ page import="org.apache.commons.io.*"%>
<%@ page import="org.apache.commons.io.filefilter.*"%>
<%@ page import="org.apache.commons.io.input.*"%>
<%@ page import="org.apache.commons.io.monitor.*"%>
<%@ page import="org.apache.commons.io.output.*"%>
<%@ page import="org.apache.commons.io.comparator.*"%>
<%@ page import="org.apache.commons.io.serialization.*" %>
<%@ page import="java.io.*,java.util.*, javax.servlet.*," %>
<!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>
<%
ServletFileUpload upload = new ServletFileUpload();
//Parse the request
List<FileItem> multifiles = upload.parseRequest(request);
try{
for(FileItem item : multifiles){
if(item.isFormField()){
out.println("sumit singh is king");
}
else{
}
}
}catch(Exception e){
out.println("sf");
}
%>
</body>
</html>
null
从game.jsp
中删除上次导入的,使用下面的代码更新
game.jsp
更新的game.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.util.*"%>
<%@ page import="org.apache.commons.io.*"%>
<%@ page import="org.apache.commons.io.filefilter.*"%>
<%@ page import="org.apache.commons.io.input.*"%>
<%@ page import="org.apache.commons.io.monitor.*"%>
<%@ page import="org.apache.commons.io.output.*"%>
<%@ page import="org.apache.commons.io.comparator.*"%>
<%@ page import="org.apache.commons.io.serialization.*" %>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<!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>
<%
ServletFileUpload upload = new ServletFileUpload();
//Parse the request
List<FileItem> multifiles = upload.parseRequest(request);
try{
for(FileItem item : multifiles){
if(item.isFormField()){
out.println("sumit singh is king");
}
else{
}
}
}catch(Exception e){
out.println("sf");
}
%>
</body>
</html>
在上一次导入中添加了额外的,这使编译器期望再次导入,请改用:
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
错误是 在路径为[/HelloWorld]的上下文中,servlet[jsp]的严重:servlet.service()引发异常[无法编译jsp的类: 我的代码是(newfile.jsp): (game.jsp):
问题内容: 创建新类时遇到了此类错误。下面是我的代码: 谁能帮助我弄清楚实际发生了什么,并提出解决建议?非常感谢您的帮助 真诚的 问题答案: 该声明 应该在代码块中,例如方法,构造函数或实例初始化程序中,而不是在类块中
所以我在第37行的else if中出现了错误,我不知道为什么会发生这种情况。IDE说:“令牌”else“语法错误,删除这个令牌”。多谢了。
谢谢!!
我有一个Larvel API,它使用Tymon\JWTAuth对用户进行身份验证。 它工作得很好。 出于某些原因,我在中还有一个非防护路由: MyController@mymethod代码如下: 我在浏览器中使用此url调用路由: 问题是我在JWT.php中有一个异常: Tymon\JWTAuth\Exceptions\JWTException需要令牌 jwt. php 我如何解码作为URL参数传
我正在做一个java自动售货机操作系统,我刚刚将我的原始项目导入到eclipse中,并添加了一个guy页面,从那以后,无论我做什么,它到处都是错误,我能得到一些帮助吗?现在的主要错误是“令牌的语法错误,错误的构造”,如果代码是坏的或者是低效率的,我会提前道歉。