0
片斷我的彈簧MVC的是角JS,彈簧MVC角JS代碼不是在彈簧工作
@RequestMapping(value = "/list2", method = RequestMethod.GET,headers="Accept=*/*",produces = "application/json")
public ResponseEntity<List<Employe>> listAllUsers() {
List<Employe> users = dataService.getList();
if(users.isEmpty()){
return new ResponseEntity<List<Employe>>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<List<Employe>>(users, HttpStatus.OK);
}
我的角的js控制器就像下面
'use strict';
變種應用= angular.module( '應用',[]);
app.controller('EmpController', function($scope, httpq) {
httpq.get('http://localhost:8080/SpringHibernate/list2')
.then(function(data) {
$scope.users = data;
})
.catch(function(data, status) {
console.error('Gists error', response.status, response.data);
})
.finally(function() {
console.log("finally finished gists");
});
});
我的index.jsp是
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head ng-app="app" >
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859- 1">
<title>SpringHibernate</title>
</head>
<body >
<h1>Welcome to Spring Hibernate Project!!!</h1>
<a href="/SpringHibernate/form">Please Click this Link To Proceed</a>
<a href="/SpringHibernate/list3">Please Click this Link To Proceed</a>
<div ng-controller="EmpController">
<!--Body content-->
<input ng-model="query"> Type to Search</input>
<ul>
<li ng-repeat="user in users | filter:query | orderBy:orderProp">
<p>{{user.firstName}}
<p>{{user.lastName}}
<p>{{user.email}}
<p>{{user.phone}}
</li>
</ul>
</div>
<script src="<c:url value="/resources/js/angular.min.js" />" type="text/javascript"></script>
<script src="<c:url value="/resources/js/app.js" />" type="text/javascript"></script>
</body>
</html>
啓動代碼我既不讓任何登錄我的瀏覽器,它看起來像角沒有執行在所有之後。請讓我知道還需要其他細節。我在Postman中使用了相同的URL,它成功地生成了JSON響應。
你在控制檯中是否有錯誤? – ochi