<%
//显示数据
i = 0;
String nr= " ";
while(i <intPageSize && result.next()){
if (result.getString( "neirong ").length> 10){
nr = result.getString( "neirong ").substring(0, 20);
}
%>
错误提示:
symbol : variable length
location: class java.lang.String
if (result.getString( "neirong ").length> 10){
^
1 error
------解决方案--------------------
length()
------解决方案--------------------
你的代码有至少3处问题:
1,String.length() 是方法,不是属性,需要带()的。
2,
if (result.getString( "neirong ").length> 10){
nr = result.getString( "neirong ").substring(0, 20);
判断长度> 10,截取却是0-20.(估计是楼主手误)。
3,“result.getString( "neirong ").length> 10”,
当result.getString( "neirong ") == null 时会出现空指针异常,
建议改成
“result.getString( "neirong ") != null
&& result.getString( "neirong ").length> 10”