0

我使用 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>
4

1 回答 1

0
<sql:param value="${param.name}"/>

有关 JSP EL 隐式对象的列表,请参阅http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html#wp71043

于 2013-03-14T14:58:45.200 回答