我使用 jstl sql 进行原型设计,并希望将它与 angularjs 一起使用。下面的代码会导致我的数据库中出现空字段。如何在 jstl sql 代码中捕获参数?
表单.html:
<form ng-submit="submit()" ng-controller="crudCtrl">
<input type="text" name="name" id="name" ng-model="name"/>
<input type="submit" name="submit" id="submit" value="Submit"/>
</form>
ctrl.js:
function crudCtrl($scope, $http) {
$scope.name = name;
$scope.url = 'create.jsp';
$scope.submit = function() {
$http({
method: 'POST',
url: $scope.url,
data: $scope.name,
headers: {'Content-type': 'application/x-www-form-urlencoded'}
}).success(function(data, status) {
$scope.status = status;
$scope.data = data;
$scope.result = data;
}).error(function(data, status) {
$scope.data = data || "Fail";
$scope.status = status;
});
}
}
创建.jsp:
<sql:update dataSource="jdbc/postgres">
INSERT INTO mySchema.test
(
name
)
VALUES(?)
<sql:param value="${name}"/>
</sql:update>