本帖最后由 kimi 于 2014-1-8 17:34 编辑
在后台设定如下:
页面是:- <%@page import="javax.servlet.http.Cookie"%>
- <%@page import="javax.servlet.http.*"%>
- <%@page import="javax.servlet.*"%>
- <%@ page contentType="text/html;charset=UTF-8" language="java"%>
- <%@page import="sun.misc.BASE64Encoder"%>
- <%@page import="sun.misc.BASE64Decoder"%>
- <%
- response.setContentType("text/html;charset=UTF-8");
- request.setCharacterEncoding("utf-8");
- BASE64Encoder encoder = new sun.misc.BASE64Encoder();
- BASE64Decoder decoder = new BASE64Decoder();
- /*String domainname = "公积金";//企业域名
- String account = "kingon";//用户账户
- String password = "kingon";//密码*/
- //String domainname = request.getParameter("domainname");//企业域名
- String domainname = "好先机培训网";//"公积金";
- String account = "8000003";//request.getParameter("account");//用户账户
- String password = "123456";//request.getParameter("password");//密码
- System.out
- .println("================================================================="
- + domainname);
- //单点登录模式平台读取用户信息需要解密,因而存储用户信息也需要加密
- Cookie cookiet = new Cookie("obpmDomainName",
- (new sun.misc.BASE64Encoder()).encode(
- domainname.trim().getBytes()).toString());
- Cookie obpmLoginAccount = new Cookie("obpmLoginAccount",
- (new sun.misc.BASE64Encoder()).encode(
- account.trim().getBytes()).toString());
- Cookie obpmLoginPassword = new Cookie("uerPassword",
- (new sun.misc.BASE64Encoder()).encode(
- password.trim().getBytes()).toString());
- //设置cookie的生命周期
- cookiet.setMaxAge(60 * 60 * 24);
- obpmLoginAccount.setMaxAge(60 * 60 * 24);
- obpmLoginPassword.setMaxAge(60 * 60 * 24);
- //设置cookie的路径
- cookiet.setPath("/");
- obpmLoginAccount.setPath("/");
- obpmLoginPassword.setPath("/");
- //添加cookie
- response.addCookie(obpmLoginAccount);
- //response.addCookie(obpmLoginPassword);
- response.addCookie(cookiet);
- session.setAttribute("IsClientLogin", true);
- response.sendRedirect("http://172.10.0.20:8080/haoxianji/portal/login/sso.action");
- //request.getRequestDispatcher("http://172.10.0.221:9090/CPF/portal/login/sso.action").forward(request, response);
- %>
- <title>demo</title>
- </head>
- <body>
- <!--<iframe name="iframe" style="display: 'none'"></iframe>
- <a href="http://localhost:8080/CPF/portal/login/sso.action">myApps平台主页</a>-->
- </body>
- </html>
复制代码 问题是每次都不能直接进入页面,都被挡在:
问下,改如何实现呢? |