初学jsp+javabean时的问题 找不到class
我的一个JSP+Javabean的练习放在如下路径
D:\J2ee\Apache Software Foundation\Tomcat 6.0\webapps\Jsp\exercises
useBean -folder 下面
-[WEB-INF] ---> Folder
-classes ----> folder
- tax ----> folder
-TaxRate.class
- TaxRate.java
-UseBean.jsp
-settax.jsp
UseBean.jsp
-----------------
<html><body><%@ page language="java" %><jsp:useBean id="taxbean" scope="application" class="tax.TaxRate" /><jsp:setProperty name="taxbean" property="*"/>产品:<jsp:getProperty name="taxbean" property="product"/><br>税率:<jsp:getProperty name="taxbean" property="rate"/></body></html>
<html><head><title>设置产品税率</title></head><body bgcolor="#fffffr"><FORM method="post" action="UseBean.jsp"> <TABLE border=0 cellspacing=1 cellpadding=5> <TR> <td width="100"> </td> <td align="right"><H1><FONT color="red">设置产品税率</FONT></H1></TD> </TR> <TR> <td width="100" align="right"><B><FONT color="blue">产品:</FONT></B></TD> <td align="left"><INPUT TYPE="text" name="product" size="30"></TD> </TR> <TR> <td width="100" align="right"><B><FONT color="blue">税率:</FONT></B></TD> <td align="left"><INPUT TYPE="text" name="rate" size="30"></TD> </TR> <TR> <td width="100"> </TD> <td align="right"></TD> </TR> <TR> <TD width="100"> </td> <td align="left"><input type="submit" value="Submit"></td> </tr> </table> </FORM> </BODY> </HTML>
package tax; public class TaxRate { double rate; String product; public TaxRate(){ } public void setProduct(String ProductName){ this.product=ProductName; } public String getProduct(){ return (this.product); } public void setRate(double rateValue){ this.rate=rateValue; } public double getRate(){ return this.rate;} }
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1233)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Generator.generate(Generator.java:3459)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
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)
如果将appBase改为如下后重启Tomact
.\Tomact6.0\conf\Server.xml 中<host 部分的缺省如下
<Host name="localhost" appBase="webapps\Jsp\exercises" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">