gpt4 book ai didi

java - 尝试执行jsp页面时收到错误消息 "Only a type can be imported..."

转载 作者:行者123 更新时间:2023-11-29 03:58:34 24 4
gpt4 key购买 nike

我有一个 jsp 页面试图引用一些用户定义的类。这些类是用以下行编译的:

package pikefin;

并放置在目录中:

/var/lib/tomcat6/webapps/examples/jsp/JSPEssbase2/WebContent/WEB-INF/classes/pikefin

这是我的 jsp 代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="pikefin.PopulateSpreadsheet" %>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
out.println(" Hello Oracle World5");
PopulateSpreadsheet tmp = new PopulateSpreadsheet();

out.println(" Hello Oracle World4"); %>
</body>
</html>

这是完整的错误信息:

type Exception report

message

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:

An error occurred at line: 6 in the generated java file
Only a type can be imported. pikefin.PopulateSpreadsheet resolves to a package

An error occurred at line: 13 in the jsp file: /jsp/JSPEssbase2/essbasedatasource.jsp
PopulateSpreadsheet cannot be resolved to a type

更新 1:

所以我将导入语句更改为:

<%@ page import="pikefin.*"%>

并创建了一个新的目录结构,如下所示:

[ollie@devdataload jsp]$ ls -Rp JSPEssbase3/
JSPEssbase3/:
essbasedatasource.jsp META-INF/ WEB-INF/

JSPEssbase3/META-INF:
MANIFEST.MF

JSPEssbase3/WEB-INF:
classes/ lib/

JSPEssbase3/WEB-INF/classes:
pikefin/

JSPEssbase3/WEB-INF/classes/pikefin:
BatchSample$CellAddress.class Logs.class
BatchSample.class PopulateSpreadsheet.class
CustomBufferedWriter.class SkipLoadException.class
DBFunctions.class TestException.class
EssbaseConnect.class UtilityFunctions.class

JSPEssbase3/WEB-INF/lib:

现在我收到此错误消息:

type Exception report

message

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:

An error occurred at line: 13 in the jsp file: /jsp/JSPEssbase3/essbasedatasource.jsp
PopulateSpreadsheet cannot be resolved to a type
10: <body>
11: <%
12: out.println(" Hello Oracle World5");
13: PopulateSpreadsheet tmp = new PopulateSpreadsheet();
14:
15: out.println(" Hello Oracle World4"); %>
16: </body>

最佳答案

路径

/var/lib/tomcat6/webapps/examples/jsp/JSPEssbase2/WebContent/WEB-INF/classes/pikefin

应该是

/var/lib/tomcat6/webapps/examples/WEB-INF/classes/pikefin

WEB-INF 必须直接放在 webapp 项目文件夹中。

关于java - 尝试执行jsp页面时收到错误消息 "Only a type can be imported...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4924412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com