刚开始学javabean...请教各位前辈我的程序哪里有问题....我把类文件放在默认包下没有建立新包...类文件Compare.java如下import java.util.Date;public class Compare{
//设置两个日期
private Date firstDate;
private Date secondDate;
/*判断*/
public String compare()
{
if(firstDate.before(secondDate))
return "第一个时间早";
else if(secondDate.before(firstDate))
return "第二个时间早";
else return "两个时间相同";
}
//取得第一个时间
public Date getFirstDate()
{
return firstDate;
}
//设置第一个时间
public void setFirstDate(Date firstDate)
{
this.firstDate=firstDate;
}
//取得第二个时间
public Date getSecondDate()
{
return secondDate;
}
//设置第二个时间
public void setSecondDate(Date secondDate)
{
this.secondDate=secondDate;
}
}
在newCompare.jsp文件如下<%@ page language="java" import="java.util.*" import="java.util.Date" pageEncoding="gb2312"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>JSP示例程序2</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<jsp:useBean id="date" class="Compare" scope="page"></jsp:useBean>
<%
date.setFirstDate(new Date());
date.setSecondDate(new Date(107,6,23));
%>
<font size="4"><strong>本页面展示比较两个日期时间的前后:</strong><br>
第一个时间:<jsp:getProperty property="firstDate" name="date"/><br>
第二个时间:<jsp:getProperty property="secondDate" name="date"/><br>
<%out.println(date.compare()); %>
</font>
</body>
</html>在myeclips中没有错误
在浏览器中报错:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 27 in the jsp file: /newCompare.jsp
Compare cannot be resolved to a typeAn error occurred at line: 34 in the jsp file: /newCompare.jsp
Compare cannot be resolved to a type我用的tomcat...
应该不是tomcat的问题,能运行其他jsp网页
应该是类文件的问题...如果要是路径有问题myeclipse应该报错,现在已经能通过,就不该是路径问题...
我的class文件在"myeclipse\工程名\WebRoot\WEB-INF\classes"中请各位前辈帮忙分析分析~~~~先谢过!
//设置两个日期
private Date firstDate;
private Date secondDate;
/*判断*/
public String compare()
{
if(firstDate.before(secondDate))
return "第一个时间早";
else if(secondDate.before(firstDate))
return "第二个时间早";
else return "两个时间相同";
}
//取得第一个时间
public Date getFirstDate()
{
return firstDate;
}
//设置第一个时间
public void setFirstDate(Date firstDate)
{
this.firstDate=firstDate;
}
//取得第二个时间
public Date getSecondDate()
{
return secondDate;
}
//设置第二个时间
public void setSecondDate(Date secondDate)
{
this.secondDate=secondDate;
}
}
在newCompare.jsp文件如下<%@ page language="java" import="java.util.*" import="java.util.Date" pageEncoding="gb2312"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>JSP示例程序2</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head>
<body>
<jsp:useBean id="date" class="Compare" scope="page"></jsp:useBean>
<%
date.setFirstDate(new Date());
date.setSecondDate(new Date(107,6,23));
%>
<font size="4"><strong>本页面展示比较两个日期时间的前后:</strong><br>
第一个时间:<jsp:getProperty property="firstDate" name="date"/><br>
第二个时间:<jsp:getProperty property="secondDate" name="date"/><br>
<%out.println(date.compare()); %>
</font>
</body>
</html>在myeclips中没有错误
在浏览器中报错:
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 27 in the jsp file: /newCompare.jsp
Compare cannot be resolved to a typeAn error occurred at line: 34 in the jsp file: /newCompare.jsp
Compare cannot be resolved to a type我用的tomcat...
应该不是tomcat的问题,能运行其他jsp网页
应该是类文件的问题...如果要是路径有问题myeclipse应该报错,现在已经能通过,就不该是路径问题...
我的class文件在"myeclipse\工程名\WebRoot\WEB-INF\classes"中请各位前辈帮忙分析分析~~~~先谢过!
解决方案 »
- s:iterator 遍历加超链接问题
- 数据库分页 还是用JavaBean分页好
- JSP系统下载功能带SESSION校验,如何支持外部下载工具?
- 一个时间格式的问题```
- @# apping file autogenerated by MyEclipse #@ 我非常想实现这个功能,哪位能教教我?
- jsp中用自定义函数返回表中对应的数据
- jar包里如何访问xml文件?!
- 关于servlet里重新定向target的问题,,急~~~
- 跪求,一个页面跳转的问题,死也搞不定,吐血了.
- 知道为什么的帮个忙解释一下:1、weblogic里面的web.xml和tomcat里面的web.xml配置为什么不同?2,是不是一定要指定servlet-mapping映射一个别名,并用那个映射名访问,而用原来那个名不行???
- 谁知道svnControl怎么安装呀,全部身家相送
- 请问jfreechart 曲线图时间轴怎样实现无论有没有数据都显示为12个月?
建议在src下建个包把Compare放进去...
>_<