方法:
将js需要获取的参数绑定到model或者ModelAndView等然后转到转发到页面(使用springMVC的视图解析器)
controller:
Map<String,Object> params= new HashMap<String, Object>();
params.put("remarkRole", UserUtils.getUserRoleId());
return new ModelAndView("/agent/order_index",params);
然后jsp取出controller传过来的值用 var remarkRole = ‘${remarkRole}’;接收
<script type="text/javascript">
var remarkRole = '${remarkRole}';
</script>
然后js直接用,这里的 remarkRole 就是 var remarkRole = ‘${remarkRole}’;中的 remarkRole
if(remarkRole == '1' || remarkRole==1){
remarkButtonhtml+="<span class='btn-span'>" +
"<a href='javascript:void(0);' title='备注' onclick='remark(" + index + ")' >备注</a>"+
"</span>" ;
}