系统对接要接入别的系统,需要自动登录进去

设计一个中转页:自动JavaScript触发表单提交即可

    /**
     * 跳转Datastudio
     * @param request request
     * @return ModelAndView
     */
    @RequestMapping("gotoDatastudio")
    public ModelAndView gotoDatastudio(HttpServletRequest request) {
        ModelAndView view = new ModelAndView("bdm/gotoDatastudio");
        String workflowUrl = configRemoteService.getByKey("big.data.studio.login.url", "http://datastudio.chinamuseum.cn:31479/login");
        workflowUrl +="?login_url="+request.getParameter("login_url");
        String username = configRemoteService.getByKey("big.data.studio.login.username", "admin");
        String password = configRemoteService.getByKey("big.data.studio.login.password", "admin");
        view.addObject("workflowUrl", workflowUrl);
        view.addObject("username", username);
        view.addObject("password", password);
        return view;
    }

HTML中转页

<!DOCTYPE html>
<!--suppress ALL-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" style="overflow: hidden;height: 100%;">
<!--/* 加载IE8兼容性片段 */-->
<head>
    <title text="平台"></title>
</head>
<body>
<div id="app">
    <div>
        加载中...
    </div>
    <form method="post" th:action="${workflowUrl}" id="submitClick"  style="display: none">
        <input type="text" name="username" th:value="${username}"/>
        <input type="password" name="password" th:value="${password}"/>
        <button type="submit">Submit</button>
    </form>
</div>
<div id="scripts">
    <script th:inline="javascript">
        $(function () {
            setTimeout(function(){
                document.getElementById("submitClick").submit();
            }, 1000);
        });
    </script>

</div>
</body>
</html>

这样延迟1秒后自动提交表单--登录第三方系统

posted on 2024-07-10 18:30  白嫖老郭  阅读(26)  评论(0编辑  收藏  举报

导航