CAS-server login interface transformation

First of all, we need to find the original login page of cas. Don’t delete the original login page, because we need to introduce the relevant resources in the original login page into our login page. Just rename the original login page at will, the original cas The login page location is as follows:

Copy the login page we need to the path of the original login page of cas, and rename it to the name of the original login page of cas, including the suffix.

Introduce the jsp related files in the original login page of cas into the login page we need (if the login page we need is HTML):

<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

Copy the style pictures and other resources that our page needs to use to the cas directory:

Replace the relevant input boxes in the form on our page with the original page, the style still retains our style:

<!-- <form class="sui-form">      我们的 form 表头 -->
<form:form class="sui-form" method="post" id="fm1" commandName="${commandName}" htmlEscape="true">    <!-- 还是替换成原来的 form 表头 引入我们的样式 -->
    <div class="input-prepend"><span class="add-on loginname"></span>
        <!-- <input id="prependedInput" type="text" placeholder="邮箱/用户名/手机号" class="span2 input-xfat"> -->
		<form:input placeholder="邮箱/用户名/手机号" class="span2 input-xfat" id="username" size="25" tabindex="1" accesskey="${userNameAccessKey}" path="username" autocomplete="off" htmlEscape="true" />
	</div>
	<div class="input-prepend"><span class="add-on loginpwd"></span>
		<!-- <input id="prependedInput" type="password" placeholder="请输入密码" class="span2 input-xfat"> -->
		<form:password placeholder="请输入密码" class="span2 input-xfat" id="password" size="25" tabindex="2" path="password"  accesskey="${passwordAccessKey}" htmlEscape="true" autocomplete="off" />
	</div>
	<div class="setting">
		<label class="checkbox inline">
			<input name="m1" type="checkbox" value="2" checked="">自动登录
		</label>
		<span class="forget">忘记密码?</span>
        <!-- 用户名 密码输入错误提示框 -->
        <form:errors path="*" id="msg" cssClass="errors" element="div" htmlEscape="false" />
	</div>
	<div class="logined">
	    <!-- <a class="sui-btn btn-block btn-xlarge btn-danger" href="home-index.html" >登&nbsp;&nbsp;录</a> -->					
		<input type="hidden" name="lt" value="${loginTicket}" />
		<input type="hidden" name="execution" value="${flowExecutionKey}" />
		<input type="hidden" name="_eventId" value="submit" />
		<input class="sui-btn btn-block btn-xlarge btn-danger" name="submit" accesskey="l" value="登&nbsp;&nbsp;录" tabindex="4" type="submit" />
	</div>
<!-- </form> -->
</form:form>

 

User name and password error prompt

1. Introduce an error message box on our login page

<form:errors path="*" id="msg" cssClass="errors" element="div" htmlEscape="false" />

Test: Enter the wrong user name and password, the prompt is in English. This prompt message is in the messages.properties file in the WEB-INF\classes directory :

authenticationFailure.AccountNotFoundException=Invalid credentials.
authenticationFailure.FailedLoginException=Invalid credentials.

2. Copy this prompt message to the end of messages_zh_CN.properties, and re-assign the Chinese binary field:

authenticationFailure.AccountNotFoundException=\u7528\u6237\u540D\u4E0D\u5B58\u5728.
authenticationFailure.FailedLoginException=\u5BC6\u7801\u9519\u8BEF.

The first is an error prompt when the user name does not exist, and the second is an error prompt when the password is incorrect.

3. Modify the read file configuration in the cas-servlet.xml file under WEB-INF :

p:defaultLocale="zh_CN

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" p:defaultLocale="zh_CN" />

 

Guess you like

Origin blog.csdn.net/weixin_42629433/article/details/84312660