我解决不了这个问题,你能帮帮我吗?
<%@ 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.service()用于servlet,在带有路径/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;
}
}

发布于 2012-01-31 13:58:46
尝试使用<jsp:setProperty>设置属性
<jsp:useBean id="musteri" class="beanler.MusteriBean" scope="request" >
<jsp:setProperty name="musteri" property="isim" value=" Ferid" />
</jsp:useBean>显示时可以使用<%=musteri.getIsim() %>
发布于 2012-01-31 14:04:37
两点你可以试一试。
初始化类属性,如
private String isim = null;
private String soyad = null;2实现可序列化的类似
public class MusteriBean implements java.io.Serializable
发布于 2012-01-31 14:13:56
我还找到了另一个解决办法。
<jsp:useBean id="musteri" class="beanler.MusteriBean" scope="request" ></jsp:useBean>我把它改成:
<jsp:useBean id="musteri" class="beanler.MusteriBean" scope="request" />这很管用..。
https://stackoverflow.com/questions/9080519
复制相似问题