在jsp中使用js獲取session中的物件的例子。
如下:
<%
String platform = Config.getString("platform.division");
String webPath = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ webPath + "/";
UserVO currUser = (UserVO)session.getAttribute("loginUser");
%>
<script type="text/javascript">
<%if (currUser==null) {%>
parent.window.location = "login.jsp";
<%} else {%>
loginUser.setValue(<%=currUser.getDept_pk()%>,"<%=currUser.getDept_name()%>","<%=currUser.getUname()%>","<%=currUser.getRole_pks()%>","<%=currUser.getRole_authority()%>","<%=currUser.getLatitude()%>","<%=currUser.getLongitude()%>","<%=currUser.getMap_zoom_level()%>","<%=currUser.getDept().getLAYER()%>");
<%}%>
var platform ="<%=platform %>";
var _dept_pk = loginUser.dept_pk;
var _dept_name = loginUser.dept_name;
var _dept_pk_edit = loginUser.dept_pk;
var _dept_name_edit = loginUser.dept_name;
var _edit_status;// 0:add;1:update
var DPK="-1";
var photoFileName = '';
var asscualZeroNodeText='';
var asscualOneNodeText='';
var asscualTwoNodeText='';
</script>