我已经在eclipse中创建了一个动态web项目,在客户端使用来自angularjs的maven 3 .i,使用spring和spring security作为后端技术。
当我运行project时,它会正确地重定向到根上下文和登录页,
但是当我想运行这个javascript时:
angular.module('common')
.controller('BaseFormCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.login = function (username, password) {
$http({
method: 'POST',
url: '/authenticate',
data: postData,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-Login-Ajax-call": 'true'
}
})
.then(function(response) {
if (response.data == 'ok') {
window.alert("login success");
}
else {
window.alert("login faild");
}
});
}
}])它返回以下错误:
POST http://localhost:8080/authenticate 404 (Not Found)但我希望它叫这个:http://localhost:8080/avl-web/authenticate
哪个avl-web是我的根上下文
发布于 2015-02-22 17:03:24
在URL开头加上'/‘将转到主机,而不管您的根上下文是什么。
'/avi-web/authenticate'包含根上下文将允许您像这样使用绝对Urls。
https://stackoverflow.com/questions/28656133
复制相似问题