servlet利用javabean向jsp端传数据为什么会出错??
javabean端的代码:
package all;
public class rsBean {
private String name;
public void set( String name)
{
this.name=name;
}
public String get()
{
return name;
}
}
servlet端的代码:
rs=selection.selectAll(conn,sql);
try {
if(rs.next())
{
String s="商品ID: "+rs.getString(2);
System.out.println(s);
rsBean rb=new rsBean();
rb.set(s);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
jsp端的代码:
<jsp:useBean id="rb" beanName="all.rsBean" type="all.rsBean" scope="session"/>
<jsp:getProperty property="name" name="rsBean"/>
结果:type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: file:/second.jsp(75,7) jsp:getProperty for bean with name 'rsBean'. Name was not previously introduced as per JSP.5.3
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1099)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1124)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Generator.generate(Generator.java:3459)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
求大神指导!!
[解决办法]
这都不懂 搓啊