主题:我的JSP日历出错,,急急
<%@ pagecontentType="text/html;charset=gb2312"%>
<%@ page language="java" import="java.util.*;java.lang.*" %>
<%
request.setCharacterEncoding("gb2312");
%>
<html><head><title>JSP日历</title></head>
<body>
<jsp:useBean id="bean" class="swing.CanlendarFace" scope="session"/>
<%
String year, month, date;
year = request.getParameter("year");
month = request.getParameter("month");
date = request.getParameter("date");
out.println(bean.showHtml(year,month,date));
%>
</body>
</html>
javabean swing.CanlendarFace.java 代码如下:
package swing.CanlendarFace;
import java.util.*;
public class CanlendarFace {
public String showHtml(String year, String month, String date) {
int y, m, d;
GregorianCalendar temp= new GregorianCalendar ();//取得当前的日历(格里高里历)
try {
y = Integer.parseInt(year);
m = Integer.parseInt(month);
d = Integer.parseInt(date);
} catch (Exception e) {
y = temp.get(GregorianCalendar.YEAR); //取得年份 ;
m = temp.get(GregorianCalendar.MONTH); //取的月份
d = temp.get(GregorianCalendar.DAY_OF_MONTH); //取的当前日
}
if (y<1900 ||y>9999) y=temp.get(GregorianCalendar.YEAR); //取得年份 ;
if (m==-1){
y--;
m=11;
}else if(m==12){
y++;
m=0;
}else if(m<-1 || m>12){
m = temp.get(GregorianCalendar.MONTH); //取的月份
}
if (d<1 || d>31) d=1;//默认日
Calendar thisMonth = Calendar.getInstance();
thisMonth.set(y, m, d);
thisMonth.setFirstDayOfWeek(Calendar.SUNDAY);
thisMonth.set(Calendar.DAY_OF_MONTH, 1);
int firstIndex = thisMonth.get(Calendar.DAY_OF_WEEK) - 1;
int maxIndex = thisMonth.getActualMaximum(Calendar.DAY_OF_MONTH);
String[] days = new String[42];
for (int i = 0; i < 42; i++) { //初始化表格数据
days[i] = " ";
}
for (int i = 0; i < maxIndex; i++) { //初始化具有实际日期值得部分
days[firstIndex + i] = String.valueOf(i + 1);
}
String face = "";
face += "<table id=\"t1\" width=\"91%\" border=\"1\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\" bordercolordark=\"#94CCF6\" bordercolorlight=\"#fefefe\">";
face += "<tr>";
face += "<td height=\"35\" colspan=\"7\" align=\"center\" bgcolor=\"#CAE8FF\">";
face += "<a href=\"daily.jsp?year="+(y-1)+"&month="+m+"&date=1\">上一年</a> ";
face += "<a href=\"daily.jsp?year="+y+"&month="+(m-1)+"&date=1\">上一月</a>";
face += "<strong class=\"STYLE4\"> " + y + " 年 " + (m +1) + " 月 </strong>";//"+d +" 日
face += "<a href=\"daily.jsp?year="+y+"&month="+(m+1)+"&date=1\">下一月</a> ";
face += "<a href=\"daily.jsp?year="+(y+1)+"&month="+m+"&date=1\">下一年</a>";
face += "</td></tr>";
face += "<tr>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\"><span class=\"STYLE3\">日</span></td>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\">一</td>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\">二</td>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\">三</td>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\">四</td>";
face += "<td width=\"14%\" align=\"center\" bgcolor=\"#C8E1FA\">五</td>";
face += "<td align=\"center\" bgcolor=\"#C8E1FA\"><span class=\"STYLE3\">六</span></td>";
face += "</tr>";
for (int j = 0; j < 6; j++) {
face += "<tr id=\"line"+ j +"\">";
String status = "status=yes,scrollbars=yes,resizable=yes,width=640,height=480";
for (int i = j * 7; i < (j + 1) * 7; i++) {
if (i==35 && days[i].equals(" ")){
face += "<script>line5.style.display=\"none\"</script>";//"<td> </td>";
break;
}
if (days[i].equalsIgnoreCase(String.valueOf(temp.get(GregorianCalendar.DAY_OF_MONTH)))&& y == temp.get(GregorianCalendar.YEAR) && m == temp.get(GregorianCalendar.MONTH)){
face += "<td bgcolor=\"#E7FEE8\" height=\"50\" align=\"center\" <span class=\"STYLE10\">";
}else if ((i%7)==0 || ((i+1)%7)==0){
face += "<td height=\"50\" align=\"center\" <span class=\"STYLE6\">";
}else{
face += "<td height=\"50\" align=\"center\" <span class=\"STYLE7\">";
}
face += days[i]+"</span>";
face += "</td>";
}
face += "</tr>";
}
face += "</table>";
return face;
}
}
运行程序出现如下错误:
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: swing/CanlendarFace (wrong name: swing/CanlendarFace/CanlendarFace)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:244)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoClassDefFoundError: swing/CanlendarFace (wrong name: swing/CanlendarFace/CanlendarFace)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:620)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1214)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)