[提问] freemarker if标签能获取对象的值,但是当作修改功能的时候就报空值的异常

xuhui784461151 2016-06-07
<script type="text/javascript">
  $(function(){
  $('#userForm').form({  
    onSubmit:function(){  
        return $(this).form('validate');  
    },  
    success:function(data){  
        updateUser(); 
    }  
});
 
//查询省
$.ajax({
  url:"${BasePath!''}/system/user/getSystemRegionList.ihtml",
  dataType:"JSON",
  data:{parentCode:0},
  success:function(data){
  if(null!=data && data.length!=0){
  var innerHtml="<option value=''>请选择省份</option>";
  var province = "${systemUserVo.province!''}";
  for(var i=0;i<data.length;i++){
  innerHtml+="<option value="+data[i].regionCode+">"+data[i].regionName+"</option>"
  }
  $("#province").html(innerHtml);
  //默认值
  if(province != ''){
  $("#province option[value='"+province+"']").attr("selected","selected");
  $("#province").change();
  }
  }else{
  $("#province").html(innerHtml);
  }
  }
  });

  //根据市
  $("#province").change(function(){
  var city = "${systemUserVo.city!''}";
  var regionCode = $("#province option:selected").val();
  var innerHtml="<option value=''>请选择城市</option>"
  if(null != regionCode && "" != regionCode){
  $.ajax({
  url:"${BasePath!''}/system/user/getSystemRegionList.ihtml",
  data:{parentCode:regionCode},
  dataType:"JSON",
  success:function(data){
  if(null!=data && data.length!=0){
 
  for(var i=0;i<data.length;i++){
  innerHtml+="<option value="+data[i].regionCode+">"+data[i].regionName+"</option>"
  }
  $("#city").html(innerHtml);
  //默认值
  if(city != ''){
  $("#city option[value='"+city+"']").attr("selected","selected");
  $("#city").change();
  }
  }else{
  $("#city").html(innerHtml);
  }
  }
  });
  }else{
  $("#city").html(innerHtml);
  }
  var lineHtml="<option value=''>请选择地区</option>";
  $("#district").html(lineHtml);
  });
 
  //查询县
  $("#city").change(function(){
  var district = "${systemUserVo.district!''}";
  var regionCode = $("#city option:selected").val();
  var innerHtml="<option value=''>请选择地区</option>"
  if(null != regionCode && "" != regionCode){
  $.ajax({
  url:"${BasePath!''}/system/user/getSystemRegionList.ihtml",
  data:{parentCode:regionCode},
  dataType:"JSON",
  success:function(data){
  if(null!=data && data.length!=0){
 
  for(var i=0;i<data.length;i++){
  innerHtml+="<option value="+data[i].regionCode+">"+data[i].regionName+"</option>"
  }
  $("#district").html(innerHtml);
  //默认值
  if(district != ''){
  $("#district option[value='"+district+"']").attr("selected","selected");
  }
  }else{
  $("#district").html(innerHtml);
  }
  }
  });
  }else{
  $("#district").html(innerHtml);
  }
  });
        });
       
        function submitCommodity(){
           $('#userForm').submit();
        }
      
function updateUser(){
var province=$('#province').val(); //省
if(province=="请选择省份"){
province="";
}
var city=$('#city').val(); //市
if(city=="请选择城市"){
city="";
}
var district=$('#district').val(); //区
if(district=="请选择地区"){
district="";
}
var url='${BasePath!''}/system/user/updateuser.ihtml';
var userName=$('#userName').val();
var loginName=$('#loginName').val();
var telPhone=$('#telPhone').val();
var sex=$('#sex').val();
var userId=$('#userId').val();
var userNo=$('#userNo').val();
var loginPassword=$('#loginPassword').val();
var lockStates=$('#lockStates').val();
var deleteFlag=$('#deleteFlag').val();
var email=$('#email').val();
var mobilePhone=$('#mobilePhone').val();
var qqNum=$('#qqNum').val();
var msnNum=$('#msnNum').val();
var params='userName='+userName+'&loginName='+loginName+"&userId="+userId
+'&telPhone='+telPhone+'&email='+email+'&mobilePhone='+mobilePhone+'&qqNum='+qqNum
+'&msnNum='+msnNum+'&sex='+sex+"&province="+province+"&city="+city+"&district="+district
+'&userNo='+userNo+'&loginPassword='+loginPassword+'&lockStates='+lockStates+'&deleteFlag='+deleteFlag;
$.ajax({
type: "POST",
  url: url,
  data: params,
success: function(msg){
    var message=eval("("+msg+")");
    if(message.result){
    $.messager.alert("修改","修改用户成功!","info",function(){
        window.location.href="${BasePath!''}/system/user/searchuser.ihtml";
    });
    }
    else{
        $.messager.alert("修改","修改用户失败!");
    }
}
});
}
</script>
</head>
<body>
<#if systemUserVo??>
<div class="list_container">
<div class="list_container_top">
<span class="lct_left"></span> <span class="lct_center"><em>修改用户</em>
</span> <span class="lct_right"></span>
</div>
<div class="details_container_center">
<form id="userForm" method="post">
<div class="details_content">
<ul class="l-ul pt8">

<li><span class="l-s">真实姓名:</span>                   
                        <label>
                        <input class="easyui-validatebox"  value="${systemUserVo.userName?default("")}" id='userName' readonly="true" name='userName' type="text" maxlength='32'/>
                        </label>
                      <input type="hidden"  id='userId' name='userId' value="${systemUserVo.userId?default("")}"/>
                      <input type="hidden"  id='userNo' name='userNo' value="${systemUserVo.userNo?default("")}"/>
                      <input type="hidden"  id='loginPassword' name='loginPassword' value="${systemUserVo.loginPassword?default("")}"/>
                      <input type="hidden"  id='lockStates' name='lockStates' value="${systemUserVo.lockStates?default("")}"/>
                      <input type="hidden"  id='deleteFlag' name='deleteFlag' value="${systemUserVo.deleteFlag?default("")}"/>
                    </li>

<li><span class="l-s">性别:</span>                   
                        <label>
                      <select id="sex" name="sex" style="width:80px;">
                                <option value="0" <#if systemUserVo.sex == '0'> selected </#if> >男</option>
                                <option value="1" <#if systemUserVo.sex == '1'> selected </#if> >女</option>     
                            </select>
                        </label>                      
                    </li>
                    <li><span class="l-s">登录名:</span>                   
                        <label>
                         <input class="easyui-validatebox" value="${systemUserVo.loginName?default("")}"  readonly="true"  id='loginName' name='loginName' type="text" maxlength='16'/>
                        </label>                      
                    </li>
                    <li><span class="l-s">email:</span>                   
                        <label>
                         <input class="easyui-validatebox" missingMessage="请正确填写邮箱" data-options='required:true,validType:"email"' id='email' name='email' type="text" maxlength='32' value="${systemUserVo.email?default("")}"/>
                        </label>                      
                    </li>
                    <li><span class="l-s">电话:</span>                   
                        <label>
                         <input class="easyui-validatebox" id='telPhone' data-options='validType:"phone"'  name='telPhone' type="text" value="${systemUserVo.telPhone?default("")}" maxlength='24'/>
                        </label>                      
                    </li>
                   
                    <li><span class="l-s">手机:</span>                   
                        <label>
                         <input class="easyui-numberbox" id='mobilePhone' data-options='validType:"mobile"' name='mobilePhone' type="text" maxlength='12' value="${systemUserVo.mobilePhone?default("")}"/>
                        </label>                      
                    </li>
                    <li><span class="l-s">QQ号码:</span>                   
                        <label>
                         <input class="easyui-numberbox" id='qqNum' data-options='validType:"qq"' name='qqNum' type="text" maxlength='16' value="${systemUserVo.qqNum?default("")}"/>
                        </label>                      
                    </li>
                    <li><span class="l-s">MSN号码:</span>                   
                        <label>
                         <input class="easyui-validatebox" id='msnNum' name='msnNum' data-options='validType:"msn"' maxlength='32' type="text" style='width:200px;' value="${systemUserVo.msnNum?default("")}"/>
                        </label>                      
                    </li>
                    <li><span class="l-s">地区:</span>
                    <select id="province" name="province"><option value="">请选择省份</option></select>
<select id="city" name="city"><option value="">请选择城市</option></select>
<select id="district" name="district"><option value="">请选择地区</option></select>
                    </li>
</ul>
</div>

<div class="details_op">
<a href="javascript:void(0)" onclick='javascript:submitCommodity();'> <span>修改</span> </a>
                <a href="${BasePath!''}/system/user/searchuser.ihtml"> <span>返回</span> </a>
</div>
</form>
</div>
</div>
</#if>
</body>

点击修改,出现Expression systemUserVo is undefined on line 61, column 83 in system/edit_system_user.ftl.
The problematic instruction:
----------
==> ${systemUserVo.province!''} [on line 61, column 81 in system/edit_system_user.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression systemUserVo is undefined on line 61, column 83 in system/edit_system_user.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)这个异常,很奇怪,为什么有值还会出现这个呢?
jimmy.shine 2016-06-30
systemUserVo这个对象为空或者不存在!
Global site tag (gtag.js) - Google Analytics