我正在使用REST开发ATG门户,所有的ATG都是使用PostMan进行测试的。当我开始在JS中工作时,它产生了一个错误。下面是测试代码:
http({
method : "GET",
url : "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber"
}).then(function mySucces(response){
// localStorage.setItem("getSessionConfirmationNumer", response.data.sessionConfirmationNumber);
// localStorage.getItem("getSessionConfirmationNumer");
http({
method : "GET",
url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login?_dynSessConf="+response.data.sessionConfirmationNumber+"&login=atgcust1&password=atgcust1",
// url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login",
// data:formData
}).then(function mySucces(response){
console.log("done");
},function errorCallback(response) {
console.log(response);
});
});来自控制台的OutPut:
angular.js:10722 GET dynSessConf=9030570900570011195&login=atgcust1&password=atgcust1 409 (匿名函数)@ angular.js:10722p @ angular.js:10515g @angular.js:10222(匿名函数)@angular.js:14745n$dynSessConf=9030570900570011195&login=atgcust1&password=atgcust1@angular.js:15989n$文摘@angular.js:15800n$apply@angular.js:16097@ angular.js:23554n.event.dispatch @jQuery-2.1.4.min.js:3r.hand-jQuery-2.1.4.min.js:3 functions.js:75 对象{data:“您的会话由于不活动而过期。”,状态: 409,配置:对象,statusText:“冲突”}
会话确认号只能访问一次,之后会产生500个内部服务器错误(这里不包括我编写的这个逻辑),
当我从浏览器手动获得会话确认号并在代码中手动将其作为_dynSessConf值时,登录就可以工作了。
请帮帮忙。
发布于 2016-06-06 06:31:10
像org.json这样的一些JSON库在解析大型longs时遇到了问题。对于大型长,它们产生的值略有不同,这正是我的代码所发生的,
通过JSON返回的SessionConfirmationNumber作为Long的数据类型返回,当SessionConfirmationNumber很大时,我得到了圆整的值。
我已经使用xmlHttp请求来解决这个问题。
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber", false );
xmlHttp.send();
console.log(xmlHttp.responseText);感谢上帝:)
https://stackoverflow.com/questions/37593360
复制相似问题