在JSP中使用JavaBean时出现异常
我无法解决这个问题,你能帮我吗?
<%@ 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>Insert title here</title>
</head>
<body>
<jsp:useBean id="musteri" class="beanler.MusteriBean" scope="request" ></jsp:useBean>
<%musteri.setIsim("Ferid");%>
<%=musteri.getIsim() %>
</body>
</html>
异常:严重:servlet [jsp] 的 Servlet.service() 在上下文中 路径 [/Servlet_Projesi] 抛出异常 [/beanTest.jsp(第 11 行, 列:0) useBean 类属性的值 beanler.MusteriBean 无效。] 根本原因 org.apache.jasper.JasperException:/beanTest.jsp(行:11,列:0) useBean 类属性 beanler.MusteriBean 的值为 无效。
package beanler;
public class MusteriBean {
private String isim;
private String soyad;
public String getIsim() {
return isim;
}
public void setIsim(String isim) {
this.isim = isim;
}
public String getSoyad() {
return soyad;
}
public void setSoyad(String soyad) {
this.soyad = soyad;
}
}
I can't solve this problem can you help me please.
<%@ 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>Insert title here</title>
</head>
<body>
<jsp:useBean id="musteri" class="beanler.MusteriBean" scope="request" ></jsp:useBean>
<%musteri.setIsim("Ferid");%>
<%=musteri.getIsim() %>
</body>
</html>
EXCEPTION: SEVERE: Servlet.service() for servlet [jsp] in context with
path [/Servlet_Projesi] threw exception [/beanTest.jsp (line: 11,
column: 0) The value for the useBean class attribute
beanler.MusteriBean is invalid.] with root cause
org.apache.jasper.JasperException: /beanTest.jsp (line: 11, column: 0)
The value for the useBean class attribute beanler.MusteriBean is
invalid.
package beanler;
public class MusteriBean {
private String isim;
private String soyad;
public String getIsim() {
return isim;
}
public void setIsim(String isim) {
this.isim = isim;
}
public String getSoyad() {
return soyad;
}
public void setSoyad(String soyad) {
this.soyad = soyad;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在显示时使用
设置属性,您可以使用
<%=musteri.getIsim() %>
try to set the property by using
<jsp:setProperty>
while displaying you can use
<%=musteri.getIsim() %>
有两点你可以尝试一下。
[1]初始化你的类属性,如
[2][非强制]实现可序列化,如
public class MusteriBean Implements java.io.Serialized
Two points you can give a try.
[1]Initialise your class properties like
[2][Not mandatory]implement Serializable like
public class MusteriBean implements java.io.Serializable
我还找到了另一个解决方案。
我将其更改为:
并且有效..
I also found another solution.
I changed it to:
and that works..