我想学PLC西门子编程培训有会的吗

校园的移动wifi电脑能连接成功 但是网页不能自动跳转成登录页面_百度知道
校园的移动wifi电脑能连接成功 但是网页不能自动跳转成登录页面
手机连接就能连接上 电脑不行
没有验证获取上网权限。这种免费wifi一般都需要通过手机获取验证码才能上网。链接成功后通过IE访问会先进入验证页面,然后通过手机获取验证码,之后才能正常上网,如果已获取,建议检查电脑是否配置过静态IP,清除IP后测试。
采纳率:70%
是不是你的浏览器不兼容,或者用兼容模式打开试试,有的网页只有兼容模式才能打开。
本回答被提问者采纳
为您推荐:
其他类似问题
移动wifi的相关知识
等待您来回答&两周内记住我
你也可以使用这些帐号登录
您的当前位置:
shiro 登录成功后,跳转到登录前的页面
转载,原文链接地址:
问题描述日,ipwin网站有自己的tools页面,是发布在前端的,如清理更新服务端的类别缓存等,需要登录用户角色为admin才可以进行操作,所以直接登入www./tools若未登录或权限不正确的话会跳转到用户登录界面,登录成功后会跳转到主页。现在想更改为从tools页面过来的登录请求,登录成功后应该重新返回tools页面。需求简单描述即为登录成功后,跳转到登录前的页面。解决方案网上找了好久,都没有找到好的解决方案,有说放入cookie的,放入session的,麻烦不实用,而且问题也一堆。最后在csdn找到一个博主的shiro使用系统文章,相当不错,解决了我的问题。系列文章地址:解决问题文章:现摘录部分如下:shiro在跳转前有记录跳转前的页面。前没有认证的用户请求需要认证的链接时,shiro在跳转前会把跳转过来的页面链接保存到session的attribute中,key的值叫shiroSavedRequest,我们可以能过WebUtils类拿到。当用户登录成功后,可能通过String url = WebUtils.getSavedRequest(request).getRequestUrl();,拿到跳转到登录页面前的url,然后redirect到这个url。其实我们可以看看这个方法的源码:public&static&SavedRequest&getSavedRequest(ServletRequest&request)&{
&&&&SavedRequest&savedRequest&=&
&&&&Subject&subject&=&SecurityUtils.getSubject();
&&&&Session&session&=&subject.getSession(false);
&&&&if&(session&!=&null)&{
&&&&&&&&savedRequest&=&(SavedRequest)&session.getAttribute(SAVED_REQUEST_KEY);
&&&&return&savedR
}从session中拿到SaveRequest。不过值得注意的是,这个SaveRequest是在用户通过上面方式跳转登录时shiro才会保存,并且不会改变,除非下一次跳转再次发生。并不是每一个请求,shiro都会把上一个请求保存到session中。所以,不能通过WebUtils.getSavedRequest(request)在任何地方调用来拿到上一个页面的请求。这个方法的调用,更应该是在用户登录成功后,重定向到页面时使用。以下代码是我使用springmvc在登录成功后的部分处理/**&用户登录页面&*/
@RequestMapping(value&=&&/user/login&,&method&=&RequestMethod.POST)
public&String&loginpost(ModelMap&model,&@ModelAttribute(&user&)&ExtUserBean&userBean,&HttpServletRequest&request)&{
&&&&if&(userService.loginpost(model,&userBean))&{
&&&&&&&&SavedRequest&savedRequest&=&WebUtils.getSavedRequest(request);
&&&&&&&&//&获取保存的URL
&&&&&&&&if&(savedRequest&==&null&||&savedRequest.getRequestUrl()&==&null)&{
&&&&&&&&&&&&return&&redirect:/index&;
&&&&&&&&return&&redirect:&&+&savedRequest.getRequestUrl();
&&&&}&else&{
&&&&&&&&return&&/user/login&;
}重点在于WebUtils.getSavedRequest(request)的使用!
提供技术支持
京ICP备号-2
Copyright (C) , , All Rights ReservedMVC4项目中验证用户登录一个特性就搞定
我的图书馆
MVC4项目中验证用户登录一个特性就搞定
在开发过程中,需要用户登陆才能访问指定的页面这种功能,微软已经提供了这个特性。
& & // 摘要:& & // & & 表示一个特性,该特性用于限制调用方对操作方法的访问。& & [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]& & public class AuthorizeAttribute : FilterAttribute, IAuthorizationFilter
但是,美中不足的是,需要微软自带的一些用户验证的东西,比如数据库,配置等等的。
常常我们只需要用SESSION或者Cookies去保存用户登录状态的时候,这岂不是杀鸡用牛刀的感觉?
那么,我们按照微软官方的这个特性,重写一个属于自己的验证特性类就行了。下面是我常用的自己写的一段代码,希望大家用得开心,如果有异议可以自己修改,代码无版权,哈哈,我们只为共享。下面也提供了一个可以直接引用的DLL,需要.NET 4.0 Framework的支持。
下载地址:
using System.Web.Mnamespace System{& & /// &summary&& & /// 表示需要用户登录才可以使用的特性& & /// &para&如果不需要处理用户登录,则请指定AllowAnonymousAttribute属性&/para&& & /// &/summary&& & [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]& & public class AuthorizationAttribute : FilterAttribute, IAuthorizationFilter& & {& & & & /// &summary&& & & & /// 默认构造函数& & & & /// &/summary&& & & & public AuthorizationAttribute()& & & & {& & & & & & String authUrl = System.Configuration.ConfigurationManager.AppSettings["AuthUrl"];& & & & & & String saveKey = System.Configuration.ConfigurationManager.AppSettings["AuthSaveKey"];& & & & & & String saveType = System.Configuration.ConfigurationManager.AppSettings["AuthSaveType"];& & & & & & if (String.IsNullOrEmpty(authUrl))& & & & & & {& & & & & & & & this._AuthUrl = "/User/Login";& & & & & & }& & & & & & else& & & & & & {& & & & & & & & this._AuthUrl = authU& & & & & & }& & & & & & if (String.IsNullOrEmpty(saveKey))& & & & & & {& & & & & & & & this._AuthSaveKey = "LoginedUser";& & & & & & }& & & & & & else& & & & & & {& & & & & & & & this._AuthSaveKey = saveK& & & & & & }& & & & & & if (String.IsNullOrEmpty(saveType))& & & & & & {& & & & & & & & this._AuthSaveType = "Session";& & & & & & }& & & & & & else& & & & & & {& & & & & & & & this._AuthSaveType = saveT& & & & & & }& & & & }& & & & /// &summary&& & & & /// 构造函数重载& & & & /// &/summary&& & & & /// &param name="loginUrl"&表示没有登录跳转的登录地址&/param&& & & & public AuthorizationAttribute(String authUrl)& & & & & & : this()& & & & {& & & & & & this._AuthUrl = authU& & & & }& & & & /// &summary&& & & & /// 构造函数重载& & & & /// &/summary&& & & & /// &param name="loginUrl"&表示没有登录跳转的登录地址&/param&& & & & /// &param name="saveKey"&表示登录用来保存登陆信息的键名&/param&& & & & public AuthorizationAttribute(String authUrl, String saveKey)& & & & & & : this(authUrl)& & & & {& & & & & & this._AuthSaveKey = saveK& & & & & & this._AuthSaveType = "Session";& & & & }& & & & /// &summary&& & & & /// 构造函数重载& & & & /// &/summary&& & & & /// &param name="authUrl"&表示没有登录跳转的登录地址&/param&& & & & /// &param name="saveKey"&表示登录用来保存登陆信息的键名&/param&& & & & /// &param name="saveType"&表示登录用来保存登陆信息的方式&/param&& & & & public AuthorizationAttribute(String authUrl, String saveKey, String saveType)& & & & & & : this(authUrl, saveKey)& & & & {& & & & & & this._AuthSaveType = saveT& & & & }& & & & private String _AuthUrl = String.E& & & & /// &summary&& & & & /// 获取或者设置一个值,改值表示登录地址& & & & /// &para&如果web.config中未定义AuthUrl的值,则默认为/User/Login&/para&& & & & /// &/summary&& & & & public String AuthUrl& & & & {& & & & & & get { return _AuthUrl.Trim(); }& & & & & & set& & & & & & {& & & & & & & & if (String.IsNullOrEmpty(value))& & & & & & & & {& & & & & & & & & & throw new ArgumentNullException("用于验证用户登录信息的登录地址不能为空!");& & & & & & & & }& & & & & & & & else& & & & & & & & {& & & & & & & & & & _AuthUrl = value.Trim();& & & & & & & & }& & & & & & }& & & & }& & & & private String _AuthSaveKey = String.E& & & & /// &summary&& & & & /// 获取或者设置一个值,改值表示登录用来保存登陆信息的键名& & & & /// &para&如果web.config中未定义AuthSaveKey的值,则默认为LoginedUser&/para&& & & & /// &/summary&& & & & public String AuthSaveKey& & & & {& & & & & & get { return _AuthSaveKey.Trim(); }& & & & & & set& & & & & & {& & & & & & & & if (String.IsNullOrEmpty(value))& & & & & & & & {& & & & & & & & & & throw new ArgumentNullException("用于保存登陆信息的键名不能为空!");& & & & & & & & }& & & & & & & & else& & & & & & & & {& & & & & & & & & & this._AuthSaveKey = value.Trim();& & & & & & & & }& & & & & & }& & & & }& & & & private String _AuthSaveType = String.E& & & & /// &summary&& & & & /// 获取或者设置一个值,该值表示用来保存登陆信息的方式& & & & /// &para&如果web.config中未定义AuthSaveType的值,则默认为Session保存&/para&& & & & /// &/summary&& & & & public String AuthSaveType& & & & {& & & & & & get { return _AuthSaveType.Trim().ToUpper(); }& & & & & & set& & & & & & {& & & & & & & & if (String.IsNullOrEmpty(value))& & & & & & & & {& & & & & & & & & & throw new ArgumentNullException("用于保存登陆信息的方式不能为空,只能为【Cookie】或者【Session】!");& & & & & & & & }& & & & & & & & else& & & & & & & & {& & & & & & & & & & _AuthSaveType = value.Trim();& & & & & & & & }& & & & & & }& & & & }& & & & /// &summary&& & & & /// 处理用户登录& & & & /// &/summary&& & & & /// &param name="filterContext"&&/param&& & & & public void OnAuthorization(AuthorizationContext filterContext)& & & & {& & & & & & if (filterContext.HttpContext == null)& & & & & & {& & & & & & & & throw new Exception("此特性只适合于Web应用程序使用!");& & & & & & }& & & & & & else& & & & & & {& & & & & & & & switch (AuthSaveType)& & & & & & & & {& & & & & & & & & & case "SESSION":& & & & & & & & & & & & if (filterContext.HttpContext.Session == null)& & & & & & & & & & & & {& & & & & & & & & & & & & & throw new Exception("服务器Session不可用!");& & & & & & & & & & & & }& & & & & & & & & & & & else if (!filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) && !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))& & & & & & & & & & & & {& & & & & & & & & & & & & & if (filterContext.HttpContext.Session[_AuthSaveKey] == null)& & & & & & & & & & & & & & {& & & & & & & & & & & & & & & & filterContext.Result = new RedirectResult(_AuthUrl);& & & & & & & & & & & & & & }& & & & & & & & & & & & }& & & & & & & & & & & && & & & & & & & & & case "COOKIE":& & & & & & & & & & & & if (!filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true) && !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))& & & & & & & & & & & & {& & & & & & & & & & & & & & if (filterContext.HttpContext.Request.Cookies[_AuthSaveKey] == null)& & & & & & & & & & & & & & {& & & & & & & & & & & & & & & & filterContext.Result = new RedirectResult(_AuthUrl);& & & & & & & & & & & & & & }& & & & & & & & & & & & }& & & & & & & & & & & && & & & & & & & & & default:& & & & & & & & & & & & throw new ArgumentNullException("用于保存登陆信息的方式不能为空,只能为【Cookie】或者【Session】!");& & & & & & & & }& & & & & & }& & & & }& & }}
然后在Web.Config文件里面加入下面几句用于配置登陆验证的一些信息:
& &appSettings&& & &add key="AuthUrl" value="/User/Login" /&& & &add key="AuthSaveKey" value="LoginedUser" /&& & &add key="AuthSaveType" value="Session" /&& &/appSettings&
使用实例:
//...省略引用namespace MrHuo.Framework.Blog{& & [Authorization]//如果将此特性加在Controller上,那么访问这个Controller里面的方法都需要验证用户登录状态& & public class UserController:Controller& & {& & & & [AllowAnonymous]//这里是一个特例,有这个特性,表示这个方法不需要验证用户登录状态& & & & public ActionResult Index()& & & & {& & & & & & //...省略具体代码& & & & }& & & & //这里的方法需要验证登录状态,以下雷同& & & & public ActionResult Create()& & & & {& & & & & & //...省略具体代码& & & & }& & }}
TA的推荐TA的最新馆藏

我要回帖

更多关于 我想学编程 的文章

 

随机推荐