日期:2014-05-16  浏览次数:20310 次

新手 Ext js 登录后页面的安全性
本人ext js新手,问个白白的问题,望各位大虾们喷下。
学了例子做了个登录系统,
一个登录页面login.html里 用户输入用户名和密码 然后跳转到另一页面 index.html;
现在问题是:
假如 login.html地址为http://localhost:8080/Pro_1/login.html
而index.html为http://localhost:8080/Pro_1/index.html
这样,直接输入index.html地址就可以访问到index.html。
请问这个问题要怎么解决呢?给个方向或者方法啊。
最好有个例子学学。


------解决方案--------------------
动态页面可以用sesseion判断
aspx:
if(Session["user"]==null){
Response.Redirect('login.html');
return;
}
------解决方案--------------------
1. index不使用 .html, 改用动态页面. 在页面里作登录检测
2. 在index.html里面调用的页面/异步调用里面作登录检测
------解决方案--------------------
所有需要做登录限制的页面都改成动态页面(jsp、asp、php等等皆可),在页面开始部分检测session,不存在就跳转到登录页面;登录后添加session,跳转回原页面。
------解决方案--------------------
JScript code
<script type="text/javascript">
    var userName = document.getElementById('userName');
    if(!userName){
        window.location.href="http://localhost:8080/shsDemo/login.jsp";
    }
    
</script>