2013-02-03 3 views
0

하나의 bean이 다른 bean에 의존 할 때 작업을 시도하고 있습니다.JSP 종속성이 오류를 던지고

내가 코드의 조각

Lion.java 다음 wriiten 한

public class Lion 

{ 
private String Lname; 

public String getLname() 
{ 
return Lname; 
} 
public void setLname(String lname) 
{ 
Lname = lname; 
} 

} 

Zoo.java 패키지 com.example;

public class Zoo 
{ 
private Lion lion; 
private String address; 
public Lion getLion() 
{ 
return lion; 
} 
public void setLion(Lion lion) 
{ 
this.lion = lion; 
} 
public String getAddress() 
{ 
return address; 
} 
public void setAddress(String address) 
{ 
this.address = address; 
} 

} 

과 JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Zoo</title> 
</head> 
<body> 
<jsp:useBean id="zoo" class="com.example.Zoo" scope="request" /> 
<jsp:setProperty name="zoo" property="address" value="bannerghatta" /> 
<jsp:setProperty name="zoo" property="lion" value="${lion}" /> 
<jsp:useBean id="lion" class="com.example.Lion" scope="request" /> 
<jsp:setProperty name="lion" property="Lname" value="Shera" /> 
</body> 
</html> 

그러나 그 오류 던지는 : -org.apache.jasper.JasperException : 유형의 빈 재산 'LNAME'에 대한 정보를 찾을 수 없습니다 '를 com.example .Lion '

설명해주십시오.

답변

0

JSP의 속성 참조는 lname이어야하며 Lname이 아니어야합니다. 자세한 내용은 this article을 확인하십시오.

전체 참조 정보는 Sun의 this PDF입니다. (8.8 절 - 유추 된 이름의 대문자 사용).

+0

라이온 이름을 인쇄 할 때 이것을 사용하고 있습니다. - $ {zoo.lion.lname} ... 그러나 $ {zoo.address}의 인쇄 주소를 올바르게 사용하고있을 때 인쇄하지 않습니다. – user728907

+0

사자가 있습니까? 범위에서 ddewaele

+0

jsp : setProperty를 변경하여 Lname 대신 lname을 사용하여 (JasperException을 유발 함) – ddewaele

관련 문제