jsp tomcat javaweb
程序目的使:用MVC模型,让cal_1jsp作为 【V】和【C】,结合CalBean.java【M】,实现一个简单的计算器功能。可是程序部署后访问http://localhost:8080/myday10/cal_1.jsp。总是提示这个错误,好像是什么服务器内部错误。这是怎么回事???错误提示如下:哪位大神帮忙下我也可以把项目文件给发过去。求帮忙!!!!
::HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:630)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.cal_005f1_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:200)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:628)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.35
1)这个是cal_1.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cn.itcast.web.jsp.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body><jsp:useBean id="cb" class="cn.itcast.web.jsp.CalBean" scope="page"></jsp:useBean>
<jsp:setProperty name="cb" property="*" />
<%
cb.cal();
%>
<jsp:getProperty property="cb" name="firstNum" />
<jsp:getProperty property="cb" name="operator" />
<jsp:getProperty property="cb" name="secondNum" />
=
<jsp:getProperty property="cb" name="result" />
<hr />
<!-- V -->
<form action="/myday10/cal_1" method="post">
<table border="1" align="center">
<caption>简单计算器</caption>
<tr><th>第一个参数:</th>
<td>
<input type="text" name="firstNum" />
</td>
</tr>
<tr><th>运算符:</th>
<td><select name="operator">
<option value="+" selected="selected">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select></td></tr>
<tr><th>第二个参数:</th>
<td><input type="text" name="secondNum" /></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" / value="计算">
</td></tr>
</table>
</form>
</body>
</html>
2)这个是:CalBean.java:
package cn.itcast.web.jsp;
import java.math.BigDecimal;
public class CalBean {
private double firstNum;
private char operator;
private double secondNum;
private double result;
public double getFirstNum() {
return firstNum;
}
public void setFirstNum(double firstNum) {
this.firstNum = firstNum;
}
public char getOperator() {
return operator;
}
public void setOperator(char operator) {
this.operator = operator;
}
public double getSecondNum() {
return secondNum;
}
public void setSecondNum(double secondNum) {
this.secondNum = secondNum;
}
// 保留一位小数点
public double getResult() {
BigDecimal bd = new BigDecimal(this.result).setScale(2,
BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
}
public void setResult(double result) {
this.result = result;
}
public CalBean() {
}
public void cal() {
switch (this.operator) {
case '+':
this.result = this.firstNum + this.secondNum;
break;
case '-':
this.result = this.firstNum - this.secondNum;
break;
case '*':
this.result = this.firstNum * this.secondNum;
break;
case '/':
this.result = this.firstNum / this.secondNum;
break;
}
}
}
--------------------编程问答-------------------- 你的tomcat能启动么?访问http://localhost:8080/ 能否正确显示那只小猫?
还有你的开发工具是什么? --------------------编程问答-------------------- 能 ,会出现那个小猫。我用的是myeclipse --------------------编程问答--------------------
http://zhidao.baidu.com/link?url=t3Q6OL2ndXaN05LRYja_WI12Ko2P3OykkUgg5P2-jcWEBjmPQxSMFMyryffrjbaM7QDx6zjh-ULkbSo4KbNeWq
看看这个能不能解决你的问题 --------------------编程问答-------------------- 目测cal_1.jsp 中语法错误 请楼主仔细检查 可以 删除cal_1.jsp中可能引起问题的代码 依次排除
补充:Java , Java EE