我收到错误消息:“只能导入类型。XYZ解析为包。”
有人在这里解释了原因,但是我不确定应该如何解决。仅供参考:我正在使用Eclipse。我在下面添加了执行导入的代码。java.util。*导入工作正常。
<%@ page import="java.util.*"%> <%@ page import="org.eresearch.knowledgeportal.model.Category"%> <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao"%> <% CategoryDao catDao = new CategoryDao(); ArrayList<Category> catList = catDao.selectCategory(); // %>
编辑:实际错误如下:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 7 in the generated java file Only a type can be imported. org.eresearch.knowledgeportal.model.Category resolves to a package
好,我解决了。在上一次导入中,我添加了“;” 通过复制其他代码示例。我想这是必需的标准行结尾。
所以
<%@ page import="java.util.*" %> <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao" %> <%@ page import="org.eresearch.knowledgeportal.model.Category" %>
成为
<%@ page import="java.util.*" %> <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao" %> <%@ page import="org.eresearch.knowledgeportal.model.Category;" %>