在Tomcat中运行JavaBean出现错误
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /UseBean.jsp(23,49) Unterminated <jsp:useBean tag
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:134)
org.apache.jasper.compiler.Parser.parseBody(Parser.java:1806)
org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1060)
org.apache.jasper.compiler.Parser.parseUseBean(Parser.java:1010)
org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1231)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1559)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Bean内容:
package tax;
public class TaxRate{
String product;
double rate;
public TaxRate(){
this.product= "A001 ";
this.rate=5;}
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);}
}
JSP内容:
<%@page language= "java "%>
<jsp:useBean id= "taxbean " scope= "application " class= "tax.TaxRate ">
<%
taxbean.setProduct( "A002 ");
taxbean.setRate(17);
%>
使用方法1:
<p> 产品:
<%=taxbean.getProduct()%> <br>
税率:
<%=taxb