有人可以帮我解决这个问题。这总是出错,但没有错误消息,只是 console.log。有什么好的方法来调试这个,或者你能看看这有什么问题吗?
谢谢!萨米人
function foo(){
alert('Button pressed');
var user={"id":10,"firstName":" Ted","lastName":"TESTING","age":69,"freeText":"55555","weight":55};
$.ajax({
type: "POST",
contentType: "application/json",
url: "http://localhost:8080/testSoft/webresources/entity.user/",
dataType: "json",
data: user,
success: function(data){alert(data);},
error: function(data) {
console.log('#####################error:################################'+data);
alert('addUser error: ' + data.firstName);
}
});
};
网络服务:
@POST
@Override
@Consumes({"application/xml", "application/json"})
public void create(User entity) {
super.create(entity);
}
用户
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Size(max = 45)
@Column(name = "firstName")
private String firstName;
@Size(max = 45)
@Column(name = "lastName")
private String lastName;
@Column(name = "age")
private Integer age;
@Lob
@Size(max = 65535)
@Column(name = "freeText")
private String freeText;
@Column(name = "weight")
private Integer weight;