充值卡类型名称
<select id="ctName">
<option value="0">全部</option>
<%
List<TCardTypeEntity> ctList=(List<TCardTypeEntity>)request.getAttribute("tcteList");
if(ctList!=null && ctList.size()!=0){
for(TCardTypeEntity tcte : ctList){
if(tcte.getName()!=null){
%>
<option value="<%=tcte.getName()%>"><%=tcte.getName()%></option>
<%
}
}
}
%>
</select>
数据库中有两条记录,如下
select * from tcard_type where name is NULL;id name tetmemo int1 AllowSale
137 null null null 0
138 null null null 0控制台报错如下:
[11:07:54,250] [InsertTag$InsertHandler,922] - ServletException in '/umanage/minstall/cardInstall.jsp': null
org.apache.jasper.JasperException: An exception occurred processing JSP page /umanage/minstall/cardInstall.jsp at line 5451: List<TCardTypeEntity> ctList=(List<TCardTypeEntity>)request.getAttribute("tcteList");
52: if(ctList!=null && ctList.size()!=0){
53: for(TCardTypeEntity tcte : ctList){
54: if(tcte.getName()!=null){
55: %>
56: <option value="<%=tcte.getName()%>"><%=tcte.getName()%></option>
57:
<%
是不是在.jsp页面 tcte.getName的值不能为null????把数据库中的这两条记录删除了,刷新页面就可以显示页面,请高人指点,谢谢!
换成
null!=tcte.getName()
试一试
%>
<option value="<%=tcte.getName()%>"><%=tcte.getName()%></option>
<%
CREATE TABLE `tcard_type` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`txtmemo` varchar(100) default NULL,
`int1` int(11) default NULL,
`AllowSale` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312所以tcte.getName();有时候会null!但是tcte.getName()
String a = null;
if (a == null) {
System.out.println(a);
}问题只能是 null值 被调用了,类似于让JVM执行: null.getName();