htmlフォームからjava restメソッドにデータとしてパラメータとして取得できません。 はここに私のhtmlや角度コードです:HTMLフォームから値を取得するとNESTが返されます
var app=angular.module("myApp",[]);
app.controller("mycon",function($scope,$http){
console.log("entered here1");
$scope.test={};
$scope.add = function() {
console.log("entered here2");
var json=JSON.stringify($scope.test);
console.log($scope.test);
console.log(json);
$http.get("rest/xyz/role",
{
data:json
}
).success(function(data, status, headers, config) {
$scope.data = data;
}).error(function(data, status, headers, config) {
alert("error");
})
}});
<body ng-app="myApp" ng-controller="mycon">
<center>
<h2> Login Here! </h2>
<hr/>
<form >
<table>
<tr>
<td>Signum Id:</td>
<td><input type="text" ng-model="test.sig"/></td>
</tr>
<tr>
<button class="btn waves-effect waves-light" type="submit" ng-click="add()" name="action"> Submit <i class="material-icons right">send</i>
</tr>
</table>
</form>
</center>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
</body>
休憩コードここに行く:
@GET
@Path("/role")
@Consumes({ MediaType.APPLICATION_JSON})
//@Consumes("text/plain")
@Produces({ "application/json" })
public String list(String s) {
System.out.print("Entered here ");
System.out.print(s);
return null;
}
私は、フォームからのシグナムフィールドが残りメソッドのパラメータとして渡したいです。 出力がnullです。
あなたは 'conole.logステートメントの出力である何、あなたのバックエンド機能 – Jens
にnull'なのでを返しますか? – Jens