CAS AJAX 登入错误提示信息修改

前端之家收集整理的这篇文章主要介绍了CAS AJAX 登入错误提示信息修改前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


(1):查看 和修改 ui'view 目录 WEB-INF\cas.properties

cas.viewResolver.basename=default_v1_views


(2):创建 错误信息提示页面 WEB-INF/view/jsp/default_v1/ui/casMobileLoginErrorView.jsp

内容如下:

<%@ page contentType="application/json; charset=UTF-8"%>
{"code":"1","msg":"用户信息输入有误"}



(3):在WEB-INF/classes/default_v1_views.properties 添加如下信息:


casMobileLoginErrorView.(class)=org.springframework.web.servlet.view.JstlView
casMobileLoginErrorView.url=/WEB-INF/view/jsp/default_v1/ui/casMobileLoginErrorView.jsp


(4):修改 条件判断代码unknow/cas/server/web/AjaxLoginServiceTicketAction


  @Override
	protected Event doExecute(final RequestContext context) {
        HttpServletRequest request = WebUtils.getHttpServletRequest(context);
        
        Enumeration enu=request.getParameterNames();  
        while(enu.hasMoreElements()){  
        String paraName=(String)enu.nextElement();  
        System.out.println(paraName+": "+request.getParameter(paraName));  
        }
        
        Event event = context.getCurrentEvent();
        boolean isAjax = BooleanUtils.toBoolean(request.getParameter(BasicPropertiesReader.getInstance().getAjaxMark()));
        boolean ismobile=BooleanUtils.toBoolean(request.getParameter("ismobile"));
        System.out.println("AjaxLoginServiceTicketAction event:"+event);
        System.out.println("AjaxLoginServiceTicketAction username:"+request.getParameter("_eventId"));
        System.out.println("AjaxLoginServiceTicketAction isAjax:"+isAjax);
        System.out.println("AjaxLoginServiceTicketAction isAjax:"+BooleanUtils.toBoolean(request.getParameter("isajax")));
        
        
        if (ismobile){  
        	return new Event(this,"casMobileLoginError");
        }

    }



(5): 修改WEB-INF\login-webflow.xml文件修改如下:

下相应的Action-status 添加 如下内容


	<action-state id="loginResponse">
		<evaluate expression="ajaxLoginServiceTicketAction" />
		<!--非ajax/iframe方式登录,采取原流程处理 -->
		<transition on="success" to="warn" />
		<transition on="casMobileLoginError" to="casMobileLoginErrorView" />
		<transition on="error" to="viewLoginForm" />
		<!-- 反之,则进入 viewAjaxLoginView 页面 -->
		<transition on="local" to="viewAjaxLoginView" />
			
	</action-state>

添加view 页面ID
<end-state id="casMobileLoginErrorView" view="casMobileLoginErrorView" />
原文链接:https://www.f2er.com/ajax/160729.html

猜你在找的Ajax相关文章