主题:小菜鸟求助大哥哥-java bean!!
调试了半天还是报错!!请教前辈...
jsp:
<html>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="test.Cai" %>
<body>
<jsp:useBean id="cs" class="test.Cai" scope="session"/>
<%
cs.setNum(45);
%>
<jsp:getProperty name="cs" property="Ans"/>
</body>
</html>
java:
package test;
import java.util.*;
public class Cai
{
private int num=0;
private String ans="sdf";
public boolean dc=true;
private int ch=0;
public Cai()
{}
public void setNum(int a)
{ if(a<100&&a>1)
{
ch++;
num=a;
ans="ok";
}
else
{
ans="1<num<100!!";
dc=false;
}
}
public String getAns()
{
return ans;
}
}
报错:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot find any information on property 'Ans' in a bean of type 'test.Cai'
at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:704)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:694)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:552)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
at org.apache.jasper.compiler.Node$Visitor.visitBody
jsp:
<html>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="test.Cai" %>
<body>
<jsp:useBean id="cs" class="test.Cai" scope="session"/>
<%
cs.setNum(45);
%>
<jsp:getProperty name="cs" property="Ans"/>
</body>
</html>
java:
package test;
import java.util.*;
public class Cai
{
private int num=0;
private String ans="sdf";
public boolean dc=true;
private int ch=0;
public Cai()
{}
public void setNum(int a)
{ if(a<100&&a>1)
{
ch++;
num=a;
ans="ok";
}
else
{
ans="1<num<100!!";
dc=false;
}
}
public String getAns()
{
return ans;
}
}
报错:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot find any information on property 'Ans' in a bean of type 'test.Cai'
at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:704)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:694)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:552)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
at org.apache.jasper.compiler.Node$Visitor.visitBody