common包中有一个类PubUtil,在JSP页面中导入该类如下:
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="cn.reforger.common.PubUtil" %>
<%=PubUtil.currentDate() %> 该JSP文件放在项目根目录下正常运行,现换个目录,放到/ma_admin目录下,运行就会出错,错误信息如下: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. common.PubUtil resolves to a packageAn error occurred at line: 3 in the jsp file: /aaa.jsp
PubUtil cannot be resolved
1: <%@ page contentType="text/html;charset=gb2312" %>
2: <%@ page import="common.PubUtil" %>
3: <%=PubUtil.currentDate() %>
它好像是说PubUtil不是一个类,只是一个包???
怎么会这样?同样的代码换个目录就不能访问了??
哪位知道什么原因?
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="cn.reforger.common.PubUtil" %>
<%=PubUtil.currentDate() %> 该JSP文件放在项目根目录下正常运行,现换个目录,放到/ma_admin目录下,运行就会出错,错误信息如下: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. common.PubUtil resolves to a packageAn error occurred at line: 3 in the jsp file: /aaa.jsp
PubUtil cannot be resolved
1: <%@ page contentType="text/html;charset=gb2312" %>
2: <%@ page import="common.PubUtil" %>
3: <%=PubUtil.currentDate() %>
它好像是说PubUtil不是一个类,只是一个包???
怎么会这样?同样的代码换个目录就不能访问了??
哪位知道什么原因?
这里明显不一致啊
改为:<%@ page import="cn.reforger.common.PubUtil" %>
并且保证包放到正确的位置
一般部署到tomacat内应用,包放到tomcat lib下面,jsp的位置变了,并不需要修改什么路径问题,tomcat容器会自动加载jar包组件的