---
title: "cas4.2 使用客户端自定义页面登录一种解决方法"
author: "小于Brick"
date: "2017-05-15T11:22:18Z"
tags: ["Screen", "login", "page", "登录"]
categories: ["编程语言"]
slug: "cas4-2"
draft: false
lastmod: "2017-05-15T11:22:18Z"
id: 2374339
url: "https://youngbrick.iteye.com/blog/2374339"
---

参考：[https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen](https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen "https://wiki.jasig.org/display/CAS/Using+CAS+without+the+Login+Screen")

 

[https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form](https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form "https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form")

 

服务端：

casLoginView.jsp

 

```
<jsp:directive.include file="includes/top.jsp" />

<%
String auto = request.getParameter("auto");
if (auto != null && auto.equals("true")) {
%>
<html>
    <head>
        <script language="javascript">
            function doAutoLogin() {
                document.forms[0].submit();
            }
        </script>
    </head>
    <body onload="doAutoLogin();">

        <form id="fm1" method="post" action="<%= request.getContextPath() %>/login?service=<%= request.getParameter("service") %>">
     
            <input type="hidden" name="lt" value="${loginTicket}" />
            <input type="hidden" name="execution" value="${flowExecutionKey}" />
            <input type="hidden" name="_eventId" value="submit" />

            <input type="hidden" name="username" value="<%= request.getParameter("username") %>" />
            <input type="hidden" name="password" value="<%= request.getParameter("password") %>" />

            <% if ("true".equals(request.getParameter("rememberMe"))) {%>
                <input type="hidden" name="rememberMe" value="true" />
            <% } %>

            <input type="submit" value="Submit" style="visibility: hidden;" />
        </form>
    </body>
</html>
<%
} else {
%>

//................
//这里把casLoginView.jsp 原来的东西粘贴过来。不使用客户端登录页面时候，使用默认页面登录

<%
}
%>

<jsp:directive.include file="includes/bottom.jsp" />
```

 

 

 

客户端：

 

```
<html>
<head />
<body>
    <form method="POST" action="https://cas.example.com/cas/">
        <p>Username : <input type="text" name="username" /></p>
        <p>Password : <input type="password" name="password" /></p>
        <p>Remember me : <input type="checkbox" name="rememberMe" value="true" /></p>
        <p><input type="submit" value="Login !" /></p>
        <input type="hidden" name="auto" value="true" />
        <input type="hidden" name="service" value="http://app.example.com/myapp/" />
    </form>
</body>
</html>
```

 

 

 

```
服务端地址：
https://cas.example.com/cas/

客户端地址：
http://app.example.com/myapp/
```