private String enjoy[]; public String[] getEnjoy() { if (this.enjoy.length==0)
{
String[] ss={"足球","篮球"};
this.enjoy=ss;
}
return enjoy;
}
每次运行的时候都提示错误:org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Getter for property enjoy threw exception: java.lang.NullPointerException
{
String[] ss={"足球","篮球"};
this.enjoy=ss;
}
return enjoy;
}
每次运行的时候都提示错误:org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Getter for property enjoy threw exception: java.lang.NullPointerException
this.enjoy.length==0改成 this.enjoy==null试试
private String[] enjoy = {"足球","篮球"};
如果是重外部取的话...
public String[] getEnjoy() {
if(null == this.enjoy){
this.enjoy = new String[]{"足球","篮球"};
}
return enjoy;
}