Javascript $http.post()方法在angular js中不起作用
我正在尝试使用spring、angularjs和hibernet将数据插入数据库。 in-app.js文件控制器方法Javascript $http.post()方法在angular js中不起作用,javascript,angularjs,Javascript,Angularjs,我正在尝试使用spring、angularjs和hibernet将数据插入数据库。 in-app.js文件控制器方法 $http.post(urlBase+'/angular/insert/'+$scope.Name+'/'+$scope.City) 我不知道我犯了什么错误 AngularDate.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1
$http.post(urlBase+'/angular/insert/'+$scope.Name+'/'+$scope.City)
我不知道我犯了什么错误
AngularDate.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html ng-app="taskManagerApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AngularJS Task Manager</title>
<script data-require="angular.js@*" data-semver="1.2.13" src="http://code.angularjs.org/1.2.13/angular.js"></script>
<script src="<c:url value=" /resources/js/app.js "/>"></script>
</head>
<body>
<div ng-controller="taskManagerController">
<span>Add Task</span>
<div>
<div>
<table>
<tr>
<td> Name:</td>
<td>
<input type="text" ng-model="Name" />
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" ng-model="City" />
</td>
</tr>
<tr>
<td>
<button ng-click="addTask()" class="btn-panel-big">Add New Task</button>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
有人能帮我解决我的问题吗?这篇
$http
文章需要文章的正文,如果你有,那么就把它替换掉
$http.post(urlBase + '/angular/insert/' +$scope.Name+'/'+$scope.City)
与
或者,如果没有任何post数据,只需发送一个空的JSON对象,如
$http.post(urlBase + '/angular/insert/' +$scope.Name+'/'+$scope.City,{}).success(
function(data) {
//success code
})
//JSON data to post
var postData = {
...
...
}
$http.post(urlBase + '/angular/insert/' +$scope.Name+'/'+$scope.City, postData).success(
function(data) {
//success code
})
$http.post(urlBase + '/angular/insert/' +$scope.Name+'/'+$scope.City,{}).success(
function(data) {
//success code
})