这是一个非常棘手的问题
我正在尝试创建类型为imLol
的对象,但出现以下错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 13 in the jsp file: /yBillie.jsp
imLol cannot be resolved to a type
10: </head>
11: <body>
12: <%
13: imLol x = new imLol();
14: List<Object[]> r = x.xgetNearCoupons();
15: Users z = Users.getInstance();
16:
An error occurred at line: 13 in the jsp file: /yBillie.jsp
imLol cannot be resolved to a type
10: </head>
11: <body>
12: <%
13: imLol x = new imLol();
14: List<Object[]> r = x.xgetNearCoupons();
15: Users z = Users.getInstance();
16:
即找不到类
imLol
但同时我可以在同一类中使用对象
Users
。这是怎么回事?yBillie.jsp:
<%@page import="java.util.List"%>
<%@page import="implementations.*" %>
<%@ 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>
<%
imLol x = new imLol();
List<Object[]> r = x.xgetNearCoupons();
Users z = Users.getInstance();
%>
</body>
</html>
imLol.java:
package implementations;
import java.util.List;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
public class imLol {
public List<Object[]> xgetNearCoupons() {
Session s = Controller.getSessionFactroy().openSession();
s.beginTransaction();
String mylat = "33.207933", mylng = "35.570246";
int R = 6371;
SQLQuery query = s.createSQLQuery("SELECT * FROM Businesses WHERE CAST(business_id AS DECIMAL(10) = 1");
List<Object[]> l = query.list();
s.getTransaction().commit();
return l;
}
}
Eclipse图:
eclipse不会在
imLol
下方显示红线,但是当我将其更改为gjioarege
时,它会..在这里怎么了?
最佳答案
项目上有红色的感叹号,表示这是构建路径的问题。
您可以通过按ALT + SHIFT + Q,再按X来查看问题选项卡。
在问题选项卡中,您还将看到错误和警告。
要解决此问题,请按照下列步骤操作
JRE 或 Web服务器库可能存在问题
请勿在JSP的中编写脚本集,因为脚本集不应在JSP中使用超过十年。学习JSP的EL和JSTL,并将servlet用于Java代码。
参见How to avoid Java Code in JSP-Files?
关于java - Jsp无法将类解析为特定类的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20750938/