• 【试水CAS-4.0.3】第02节_CAS服务端登录页个性化


    完整版见https://jadyer.github.io/2015/07/16/sso-cas-login-diy/




    /**
     * @see ------------------------------------------------------------------------------------------------------------------------
     * @see CAS个性登录页
     * @see 0.cas的页面显示控制是集中在WEB-INFcas.properties中的cas.viewResolver.basename属性的,它的值默认是default_views
     * @see   所以cas会去classpath中寻找default_views.properties,在default_views.properties中指定了登录登出页面等
     * @see 1.改动cas.properties文件,cas.viewResolver.basename=msxf,再拷贝default_views.properties为msxf.properties
     * @see 2.改动msxf.properties文件,/WEB-INF/view/jsp/default改为/WEB-INF/view/jsp/msxf
     * @see   当中casLoginView.url表示默认登录页,casLoginGenericSuccessView.url表示默认登录成功页
     * @see 3.复制/WEB-INF/view/jsp/default/及其子文件夹全部文件到/WEB-INF/view/jsp/msxf/中
     * @see   接下来就能够任意改动登录页面了
     * @see   注意WEB-INFviewjspmsxfuiincludesottom.jsp页面中引用了googleapis的一些jquery库
     * @see   能够换成百度CDN(http://cdn.code.baidu.com/)的,比方http://apps.bdimg.com/libs/jqueryui/1.10.2/jquery-ui.min.js
     * @see ------------------------------------------------------------------------------------------------------------------------
     * @create 2015-7-16 下午4:56:17
     * @author 玄玉<http://blog.csdn.net/jadyer>
     */

    以下是我改动的casLoginView.jsp

    <%@ page pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    
    <c:set var="ctx" value="${pageContext.request.contextPath}" scope="session"/>
    
    <!DOCTYPE HTML>
    <html>
    <head>
    	<meta charset="UTF-8"/>
    	<title>CAS单点登录系统</title>
    	<link rel="icon" type="image/x-icon" href="${ctx}/favicon.ico"/>
    	<script type="text/javascript" src="${ctx}/js/jquery-1.10.2.min.js"></script>
    	<script type="text/javascript" src="${ctx}/js/jquery-ui-1.10.2.min.js"></script>
    	<script type="text/javascript" src="${ctx}/js/cas.js"></script>
    	<!--[if lt IE 9]>
    		<script src="${ctx}/js/html5shiv-3.7.2.min.js" type="text/javascript"></script>
    	<![endif]-->
    </head>
    
    <style>
    body {background-color: #CBE0C9;}
    #msg {padding:20px; margin-bottom:10px;}
    #msg.errors {border:1px dotted #BB0000; color:#BB0000; padding-left:100px; background:url(${ctx}/images/error.gif) no-repeat 20px center;}
    </style>
    
    <body>
    <c:if test="${not pageContext.request.secure}">
    	<div id="msg" class="errors">
    		<h2>Non-secure Connection</h2>
    		<p>You are currently accessing CAS over a non-secure connection.  Single Sign On WILL NOT WORK.  In order to have single sign on work, you MUST log in over HTTPS.</p>
    	</div>
    </c:if>
    <form:form method="post" commandName="${commandName}" htmlEscape="true">
    	<!-- 
    	cssClass用于指定表单元素CSS样式名,相当于HTML元素的class属性
    	cssStyle用于指定表单元素样式,相当于HTML元素的style属性
    	cssErrorClass用于指定表单元素错误发生时相应的样式
    	path属性用于绑定表单对象的属性值,它支持级联属性,比方path="user.userName"将调用表单对象getUser.getUserName()绑定表单对象的属性值
    	 -->
    	<form:errors path="*" id="msg" cssClass="errors" element="div" htmlEscape="false"/>
    	<input type="hidden" name="lt" value="${loginTicket}"/>
    	<input type="hidden" name="execution" value="${flowExecutionKey}"/>
    	<input type="hidden" name="_eventId" value="submit"/>
    	<table border="9">
    		<tr>
    			<td>
    				<c:if test="${not empty sessionScope.openIdLocalId}">
    					<strong>${sessionScope.openIdLocalId}</strong>
    					<input type="hidden" name="username" value="${sessionScope.openIdLocalId}"/>
    				</c:if>
    				<c:if test="${empty sessionScope.openIdLocalId}">
    					<form:input tabindex="1" path="username" placeholder="帐号" htmlEscape="true" maxlength="16" size="25"/>
    				</c:if>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<form:password tabindex="2" path="password" placeholder="密码" htmlEscape="true" maxlength="16" size="25"/>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<input type="checkbox" tabindex="3" name="warn" value="true"/>
    				<label for="warn">转向其它网站前提示我</label>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<input type="submit" tabindex="4" value="登录"/>
    			</td>
    		</tr>
    	</table>
    </form:form>
    </body>
    </html>
    以下是我改动的casGenericSuccess.jsp
    <%@ page pageEncoding="UTF-8"%>
    <body style="background-color:#CBE0C9;">
    	<span style="color:red; font-size:64px; font-weight:bold;">登录成功</span>
    </body>

    以下是效果图

    CAS-4.0.3默认登录页个性化改动


    CAS-4.0.3默认登录页提示信息个性化

    CAS-4.0.3默认登录成功页个性化

  • 相关阅读:
    JavaScript的作用域和块级作用域概念理解
    正则表达式中组的理解
    正则表达式的字符组取反(负值字符集合/范围)^必须出现在起始位置
    利用TortoiseGit(小乌龟)将项目上传至GitHub网站
    (.Net) NLog 记录日志功能
    关于网站中引用COM组件的部署问题
    备份与还原ORACLE数据库(通过CMD命令执行)
    C# Task中的Func, Action, Async与Await的使用
    ASP.NET WebAPI 项目示例(增删改查)
    .NET内存泄漏(之 静态事件)
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/7140640.html
Copyright © 2020-2023  润新知