我在html中有以下内容
<form name="myform" method="POST">
<input type="text" id="products" name="products" />
</form>
function myForm() {
var url = 'rest/products/details/';
var formData = $("#myform").serializeArray();
$.ajax({
url: url,
type: 'POST',
contentType : "application/x-www-form-urlencoded",
dataType: 'json',
data: formData,
success: function (data) {
//callfunc(data);
}
});
}
在Java服务器端我有以下
@POST
@Path("/details")
public List<Product> findProducts(@FormParam("products") String products) {
.....
.....
log.info("prod "+products); --> getting null
出于某种原因,即使我从 html 传递正确的值,产品也是 null。这可能是什么原因?