ExtJs:如何获取会话变量 [英] ExtJs:How to get Session variable
问题描述
在我的Java Web应用程序中,当用户登录时,我将用户名和其他详细信息存储在会话中,如下所示,
In my Java web application,when a user gets logged in,i store the user name and other details in session as follows,
session.setAttribute("userName",username);
我正在将ExtJs4用于UI.如何在extJs中获取会话变量?
I am using ExtJs4 for UI.How to get the session variables in extJs?
谢谢
推荐答案
我知道这个问题已经问了很久了,但是尽管有很多意见并且没有明确的答案,我还是决定提供这个答案:
I understand that the question has been asked for a long time ago, but despite the large number of views and the absence of an plain answer, I decided to offer this answer:
假设会话变量的注册方式类似于/index.php?PHPSESSID=9ebca8bd62c830d3e79272b4f585ff8f
Assume that the session variable is registered like /index.php?PHPSESSID=9ebca8bd62c830d3e79272b4f585ff8f
在这种情况下,您可以通过JS对象"location"获取变量PHPSESSID并通过Ext.Object.fromQueryString()对其进行转换
In this case, you can get the variable PHPSESSID through JS object "location" and transform it through Ext.Object.fromQueryString()
所以:
console.log( Ext.Object.fromQueryString( location.search ) );
将根据您的需要准备PHPSESSID变量.
will prepare PHPSESSID variable for your needs.
这篇关于ExtJs:如何获取会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!