系统对接要接入别的系统,需要自动登录进去
设计一个中转页:自动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秒后自动提交表单--登录第三方系统
作者:隔壁老郭
个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
Java入门到入坟
万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!