高手帮下小弟啊..
我想做一个留言本,表格中显示用户和发言标题、审核标志(bz)、发言ID(ID在数据库是唯一的)
点击标题后显示此ID的发言内容(用mm_show_id?id=12来实现,12为ID标识)
<%out.print( " <a href= 'mm_show_id.jsp?id= "+(rs.getString( "id "))+ " '> "+(rs.getString( "title "))+ " </a> ");%> 可实现此功能,但我想让BZ为空的(rs.getstring( "bz "))只显示主题,不提供链接,应怎么写上面的句子?(未经系统员审核的贴只显示标题内容,只有审核后别人才可以查贴的内容)
------解决方案-------------------- <%
if(rs.getstring( "bz ")==null ||rs.getstring( "bz ")== " "){
out.print(rs.getString( "title "));
}
else{
out.print( " <a href= 'mm_show_id.jsp?id= "+(rs.getString( "id "))+ " '> "+(rs.getString( "title "))+ " </a> ");
}
%>
------解决方案-------------------- <%if(rs.getstring( "bz ").equals( " "))
{
out.print(rs.getString( "title "));
}
else
{
out.print( " <a href= 'mm_show_id.jsp?id= "+(rs.getString( "id "))+ " '> "+(rs.getString( "title "))+ " </a> ");
}%>
------解决方案--------------------呵呵,楼上的rs.getstring( "bz ")== " "这句不行啊,JSP里不能这样比较字符串的
------解决方案--------------------楼上正确
------解决方案--------------------在链接外面套个IF来判断BZ不为空才显示链接
String bz = rs.getstring( "bz ")
if(bz!=null){
out.print( " <a href= 'mm_show_id.jsp?id= "+(rs.getString( "id "))+ " '> "+(rs.getString( "title "))+ " </a> ");
}
------解决方案--------------------嗬嗬,来晚了,来晚了。