gpt4 book ai didi

java - 来自 JSP 的重定向处于待处理类型且状态已取消

转载 作者:太空宇宙 更新时间:2023-11-04 07:52:45 26 4
gpt4 key购买 nike

我有一个 JSP 文件正在调用 REST 后调用,该调用执行对远程服务器的获取。请求正在处理中,但在远程计算机中处于待处理状态,状态为已取消。你能帮忙吗?

这是 JSP 的一部分:`

<tr>
<td><button id="registerBtn" onclick="registerClick()">Register</button></td>
<td><button id="loginBtn" onclick="postOnClick()">Log in</button></td>
</tr>
</table>
<script type='text/javascript'>
function registerClick() {

/* var params = "{realm: astra, subjectId: " + document.getElementById('usrInpt').value + " , authInfo: omsspass}"; */
var first = document.getElementById('firstNameInpt').value;
var last = document.getElementById('lastNameInpt').value;
var user = document.getElementById('usrInpt').value;
var password = document.getElementById('passInpt').value;
var email = document.getElementById('emailInpt').value;

var http = new XMLHttpRequest();

var url = "http://localhost:8080/authJ/v0/authJ/users?realm=JOES_PIZZA&uid=" + user +"&firstname=" + first + "&lastname=" + last + "&password=" + password + "&email=" + email;

//var params = "{realm: astra, subjectId: " + document.getElementById('usrInpt').value + " , authInfo: omsspass}";

http.open("POST", url, true);
//http.setRequestHeader("Content-type", "application/json");
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
document.open();
document.write(http.responseText);
}
};
http.send();
}
</script>`

这是java代码

:`@POST
@Path("/users")
public Response createUser(@QueryParam("uid")String uid, @QueryParam("firstname") String firstName, @QueryParam("lastname") String lastName, @QueryParam("email")String email,
@QueryParam("password")String password, @QueryParam("realm") String realm) {
//readProperties();
String tokenID = getToken();
StringBuffer openAmUrl = new StringBuffer().append("http://").append(openAmIp).append(openAmWarName).append("/identity/create?");
openAmUrl.append("identity_name=").append(uid);
openAmUrl.append("&identity_attribute_names=userpassword");
openAmUrl.append("&identity_attribute_values_userpassword=").append(password);
openAmUrl.append("&identity_attribute_names=sn");
openAmUrl.append("&identity_attribute_values_sn=").append(lastName);
openAmUrl.append("&identity_attribute_names=cn");
openAmUrl.append("&identity_attribute_values_cn=").append(firstName);
openAmUrl.append("&identity_realm=/").append(realm);
openAmUrl.append("&identity_type=user");
if (email != null){
openAmUrl.append("&identity_attribute_names=mail");
openAmUrl.append("&identity_attribute_values_mail=").append(email);
}
openAmUrl.append("&admin=").append(tokenID);

URI uri = null;
try {
uri = new URI(openAmUrl.toString());
} catch (URISyntaxException e) {
LOGGER.error("Exception " + e);
e.printStackTrace();
}
return Response.seeOther(uri).build();
}
`

提前致谢!

最佳答案

我发现问题是由于跨域造成的 - 我通过编辑将在没有安全性的情况下启动的浏览器的执行文件来修复它 - (--disable-web-security) 希望这对其他人有帮助!

关于java - 来自 JSP 的重定向处于待处理类型且状态已取消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14182412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com