(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":"用户信息输入有误"}
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-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