姹傚ぇ铏惧府蹇欙紒javabean鐨勪娇鐢ㄩ棶棰?锛屽皬寮熷啀娆″厛璋㈣繃浜?/a>

时间:2023-01-21 19:05:11

test_bean.jsp 濡備笅锛?/p>

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" pageEncoding="gb2312"%>

<% request.setCharacterEncoding("gb2312"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>绗竴涓猨avabean(鎴愬姛!)</title>
<style type="text/css">
<!--
.STYLE2 {
 color: #FF0000;
 font-size: 24px;
}
-->
</style>
</head>

<body> 

<jsp:useBean id="bean_id2" class="Jbean.Jbean_Exp" scope="page" >
 <jsp:setProperty name="bean_id2" property="str_jbean" value="鎴戠埍浣?lt;jsp:useBean>And</jsp:useBean>" />
</jsp:useBean>

<jsp:getProperty name="bean_id2" property="str_jbean" />

<p>&nbsp;</p>

</body>
</html>
javabean濡備笅:

// Jbean_Exp.java
package Jbean ;

public class Jbean_Exp   //java bean 鐨刢lass 蹇呴』涓簆ublic
{
 String str_jbean="" ;      //str 鍙互涓嶄负private鍨嬬殑

 public Jbean_Exp()  {}

 public void setStr(String strs)
  {
   this.str_jbean=strs ;
  }
 public String getStr()
  {
   return this.str_jbean ;
  }
}

鎶ラ敊濡備笅锛?/p>

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /MyJspWebs/SimpleJSPtext/Successed/test_bean.jsp(37,0) useBean: Duplicate bean name: {0}
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

 

root cause

org.apache.jasper.JasperException: /MyJspWebs/SimpleJSPtext/Successed/test_bean.jsp(37,0) useBean: Duplicate bean name: {0}
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:100)
	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:516)
	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.Validator.validate(Validator.java:1489)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

 

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.