我已经创建了一个登录页面。登录验证后,我希望它重定向到控制器中定义的路径。 '/home'
它重定向到http://localhost:8082/#/home
但我希望将其重定向到
http://localhost:8082/home
@Controller
public class HomeController {
@RequestMapping("/home")
public String home() {
return "index";
}
}
angular.module('myApp', []).controller('myController',
[ '$scope', '$http', '$location', function($scope, $http, $location) {
var username = "";
var password = "";
$scope.add = function() {
username = $scope.valuea;
password = $scope.valueb;
username = 'eve.holt@reqres.in';
password = 'cityslicka';
$http.post('https://reqres.in/api/login', {
email : username,
password : password
}).success(function(response) {
console.log('response:', response);
// $window.location.href = '/index.html';
//$location.path('/home');
console.log('login in successful. Redirect to path /home');
$scope.redirectToDraftPage = function() {
console.log('redirecting to /home');
$location.path('/home');
};
});
}
} ]);