cas 登陆时提示密码错误

问题描述:在登陆cas时,如果用户的用户名或者密码错误,就直接把密码清空了,但是我想让他有一句错误提示。

 

先看一下原代码:casLoginView.html

<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <!-- font files  -->
    <link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'>
    <!-- /font files  -->
    <!-- css files -->
    <link rel="stylesheet" type="text/css"  th:href="@{${#themes.code('style.css.file')}}">
    <!-- /css files -->
</head>
<script type="text/javascript">

    function a() {
        var test = window.location.href;
        document.getElementById("adds").href="http://passport.sso.com:8888/config/a.html?service="+test;
        $("#adds" ).trigger( "click" );
    }

</script>

<body style="margin: 0px;margin-top: 85px;">
<div class="div1">
    <div class="inner">

    <h1></h1>
<div class="log">
    <div class="content1" style="margin-left: 373px;">
        <h2>登录</h2>
        <form method="post" th:object="${credential}">
            <input type="text" name="username"  id="username" value="USERNAME" th:disabled="${guaEnabled}"  th:field="*{username}"  th:accesskey="#{screen.welcome.label.netid.accesskey}"  onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'USERNAME';}">
            <input type="password" name="psw" id="password" value="PASSWORD" th:field="*{password}" th:accesskey="#{screen.welcome.label.password.accesskey}" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'PASSWORD';}">
            <div class="button-row">
                <section>
                    <input type="hidden" name="execution" th:value="${flowExecutionKey}"/>
                    <input type="hidden" name="_eventId" value="submit"/>
                    <input type="hidden" name="geolocation"/>
                    <input class="sign-in"
                           name="submit"
                           accesskey="l"
                           th:value="#{screen.welcome.button.login}"
                           tabindex="6"
                           type="submit"/>
                </section>
                <a onclick="a()" id="adds" class="reset" value="Reset">注册</a>
                <div class="clear"></div>
            </div>

        </form>
    </div>

    <div class="clear"></div>
</div>
    </div>
</div>
</body>
</html>

修改:

只要在页面中加入就ok了

<div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
                        <!--//<span th:each="err : ${#fields.errors('*')}" th:utext="${err}"/>-->
                        <span th:each="err : ${#fields.errors('*')}" th:utext="用户名或密码错误" style="color: red"/>
                    </div>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CAS(Central Authentication Service)是一种单点登录协议,用于实现在多个应用系统中进行统一的身份认证和授权。CAS客户端是指集成CAS协议的应用系统,用于与CAS服务器进行通信并实现单点登录功能。 以下是CAS客户端集成单点登录的代码示例: ```java // 引入CAS客户端依赖 <dependency> <groupId>org.jasig.cas.client</groupId> <artifactId>cas-client-core</artifactId> <version>3.6.0</version> </dependency> // 配置CAS客户端 <bean id="casClient" class="org.jasig.cas.client.authentication.CasClientAuthenticationFilter"> <property name="casServerLoginUrl" value="http://localhost:8081/cas/login" /> <property name="serverName" value="http://localhost:8080" /> </bean> // 配置CAS过滤器 <filter> <filter-name>CAS Authentication Filter</filter-name> <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> <init-param> <param-name>casServerLoginUrl</param-name> <param-value>http://localhost:8081/cas/login</param-value> </init-param> <init-param> <param-name>serverName</param-name> <param-value>http://localhost:8080</param-value> </init-param> </filter> <filter-mapping> <filter-name>CAS Authentication Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> // 配置CAS单点登出过滤器 <filter> <filter-name>CAS Logout Filter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS Logout Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> // 配置CAS请求单点登出过滤器 <filter> <filter-name>CAS Request Single Sign Out Filter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS Request Single Sign Out Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ``` 以上代码是一个Java Web应用中集成CAS客户端的示例,通过配置CAS客户端和相关过滤器,实现与CAS服务器的通信和单点登录功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那个id是什么东西

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值