Java判断包含某个字符contains方法
1、这是把数据库里面的数据导出到excel中显示
2、代码如下
if (null != ar.getCbXz()){
String Str = null;
String Str1 = null;
String Str2 = null;
String Str3 = null;
if(ar.getCbXz().contains("1")){
Str1 = "交强险";
}else{
Str1 = "";
}
if(ar.getCbXz().contains("2")){
Str2 = "车损险";
}else{
Str2 = "";
}
if(ar.getCbXz().contains("3")){
Str3 = "三责";
}else{
Str3 = "";
}
Str = Str1+Str2+Str3;
sheet.addCell(new Label(10, i + 2, Str,contentStyle));// 承保险种
}else{
sheet.addCell(new Label(10, i + 2,"",contentStyle));
}

2、这是jsp页面中的显示
4、代码如下
<td align="center" nowrap="nowrap">
<c:if test="${fn:contains(item.cbXz,1) }">交强险</c:if>
<c:if test="${fn:contains(item.cbXz,3) }">三责</c:if>
<c:if test="${fn:contains(item.cbXz,2) }">车损险</c:if>
</td>

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:28
阅读量:66
阅读量:40
阅读量:169
阅读量:165