java前端常见报错整理

1.checkbox 标签已有 checked=checked 但是不显示勾选

 1 页面:
 2 <div class="col-sm-1">
 3      <label class="radio-inline">  <input type="radio" id="rdo1" name="optionsRadiosinline"  value="yes" > 4         </label> 
 5        </div>
 6        <div class="col-sm-1">
 7         <label class="radio-inline"><input type="radio" id="rdo2" name="optionsRadiosinline" value="no" > 8         </label>
 9     </div> 
10 <script type="text/javascript">
11 if('no' == data[17]){
12     $("input[name='optionsRadiosinline']:checked").removeAttr("checked");
13     $("#rdo2").attr("checked",true);
14 }
15 </script>

 

原因:这好像是本身 attr 存在的问题

解决方案:添加的时候用 prop,取消用 removeAttr。

  $("input[name='optionsRadiosinline']:checked").removeAttr("checked");

  $("#rdo2").prop("checked",true);

 

2. 值的获取 cannot be resolved to a variable

//在页面中引用 Java 类方法:
<head>
<%@ page language="java" import="kklazy.security.support.encrypt.utils.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" buffer="512kb" %>
 </head>

<script type="text/javascript">
var ceoId
= data[50];
if("" !=ceoId && null != ceoId){
$(
"#ceoId").val(<%=EncryptUtils.decode(ceoId) %>);
}
</script >

报错:ceoId cannot be resolved to a variable;

原因:在 java 代码中引入 js 中的变量,这个是不行的..
反过来如果你要在 js 中引入 java 变量,这个还是可以。

原理是:java 代码在服务器端先执行,你在 java 代码块里没有定义 ceoId,所以编译器肯定报错了。

3.org.apache.jasper.JasperException: /webpages/../../search.jsp (line: 296, column: 6) "${entity.status not eq'00'}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${entity.status not eq '00'}]

------>not eq 改成 --》ne

eq 相等 ne、neq 不相等,
gt 大于, lt 小于
gt 大于, lt 小于
gte、ge 大于等于  
lte、le 小于等于  
not 非   mod 求模  
is [not] div by 是否能被某数整除  
is [not] even 是否为偶数  
is [not] even by $b 即 ($a / $b) % 2 == 0  
is [not] odd 是否为奇  
is not odd by $b 即 ($a / $b) % 2 != 0
---------------------
作者:江户川柯南 234
来源:CSDN
原文:https://blog.csdn.net/u011461231/article/details/52849718