js对象中动态读取属性值 动态属性值 js正则表达式全局替换
$(document).ready(function(){var exceptionMsg = '${exception.message }';var exceptionstr = '';//javascript截取字符串 if(exceptionMsg!='' && exceptionMsg.indexOf("[")!=-1){
exceptionstr= exceptionMsg.substring(exceptionMsg.indexOf("[")+1,exceptionMsg.indexOf("]"));
}//java map对象变成js 字符串 var msg= "<%=Permissions.permissionExceptionMap %>";//js replaceAll 正则表达式全局替换 var jsonstr = msg.replace(new RegExp(/(=)/g),':');//jsonstr = "{aaa:'河南省'}";//后面的河南省必须要分号 var jsonObj = eval("(" + jsonstr + ")");//json字符串转 对象 //从js对象中动态读取属性值,动态属性信息 $("#aaa").html(jsonObj[exceptionstr]);
});