<button id="submit_btn" class="btn btn-primary" data-ng-click='getData();'>Get User</button>
<table border="1" width="50%" height="10%">
<tr><th>username</th><th>phone</th><th>email</th><th>Delete</th><th>edit</th></tr>
<tr data-ng-repeat="u in users">
<td><span data-ng-bind="u.userBean.username"></span></td>
<td><span data-ng-bind="u.userBean.phone"></span></td>
<td><span data-ng-bind="u.userBean.email"></span></td>
</tr>
Угловой JS
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller("UserController", ['$scope', '$http', function($scope, $http, httpPostService) {
var self=this;
$scope.getData = function()
{
$http({
method: "GET",
url: 'retrieve',
}).then(function(response) {
$scope.users = response.data;
console.log("Success");
}, function(response) {
$scope.err_state = true;
console.log("Failure");
});
};
}]);
</script>
класс контроллеров
@RequestMapping(value="/retrieve", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<UserBean> retrieves(HttpServletRequest request, HttpServletResponse response, @ModelAttribute @Valid UserBean userBean,BindingResult result)
{
List<UserBean> users=retrieveService.findAllUsers(userBean);
return users;
}
На самом деле я получаю данные из mysql во внешний интерфейс, но функция getData () не выполняется. Вот так
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/SpringAngular] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
В угловой консоли js покажите вот так
Не удалось загрузить ресурс: сервер ответил со статусом 500 ()