简体   繁体   English

发送发帖请求以从客户网站登录到服务提供商网站

[英]send post request to login from client website to service provider web

client website(asp.net) has icons on which onclick event is triggered. 客户端网站(asp.net)上具有触发onclick事件的图标。 provider website(java) onClick, 提供商网站(java)onClick,

function goTourl(){
window.open(url)
}

url is something like this: https://example.org/j_spring_security_check?name=testing&pass=testing' 网址是这样的: https://example.org/j_spring_security_check?name=testing&pass=testing' : https://example.org/j_spring_security_check?name=testing&pass=testing'

issue is, in spring 3 login submission doesn't allow get requests(i think).. 问题是,在春季3中,登录提交不允许获取请求(我认为)。

used following javascript to post but CSRF token issues comes up. 使用以下JavaScript来发布,但出现CSRF令牌问题。

function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name); 
if (!newWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values && (keys.length == values.length))
for (var i=0; i < keys.length; i++)
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
newWindow.document.write(html);
return newWindow;
}

Well your should not be setting the url in the new window in the open. 好吧,您不应该在打开的新窗口中设置网址。

var newWindow = window.open(url, name);

should be 应该

var newWindow = window.open('', name);

You could avoid the whole pop up using a form on the page with the action and target set 您可以使用设置了操作和目标的页面上的表单来避免整个弹出窗口

<form action="https://example.org/j_spring_security_check" method="post" target="_blank">
    <input type="hidden" name="foo" value="bar" />
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM