<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*,java.util.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>小脚本</title>
</head>
<body>
<% Date d=new Date();%>
<%=d%>
</body>
</html>
为什么这样都会提示出错?
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 13 in the jsp file: /Scriptlet.jsp
The type Date is ambiguous
10:
11:
12:
13: <% Date d=new Date();%>
14:
15: <%=d%>
16:
------最佳解决方案--------------------------------------------------------
sql与util包中都存在Date类,请问你是要倒哪一个.
------其他解决方案--------------------------------------------------------
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" import="java.util.Date" errorPage="" %>
应该是 java.sql.* 和 java.util.* 中都有Date产生冲突了
------其他解决方案--------------------------------------------------------
+1
可以改成java.util.Date d=new java.util.Date()
------其他解决方案--------------------------------------------------------
菜不是理由,
An error occurred at line: 13 in the jsp file: /Scriptlet.jsp
13行报错了
而13行代码为:
<% Date d=new Date();%>
就这一段 那么你认为哪里错了呢?
------其他解决方案--------------------------------------------------------
导的包呢?没util包?
------其他解决方案--------------------------------------------------------
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*,java.util.*" errorPage="" %>
------其他解决方案--------------------------------------------------------
的确是冲突了,全部都有分,结贴