请帮我解决这个问题,我在其他地方试过,但是找到任何可以解决我问题的东西..我有简单的休息服务
@POST
@Path("/appointmentService")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Appointment saveAppointmentToDB(Appointment appointment)
{
System.out.println("inAppointment");
ObjectToDataBase otd = new ObjectToDataBase();
Appointment appointmentSaved = (Appointment)otd.saveObjectToDatabase(appointment);
return appointmentSaved;
}
我试图使用以下
从Ajax查询中调用它jQuery(document).on('ready', function() {
jQuery('form#add-new-task').bind('submit', function(event){
event.preventDefault();
var form = this;
var json = ConvertFormToJSON(form);
window.alert(JSON.stringify(json));
var tbody = jQuery('#to-do-list > tbody');
$.ajax({
type: 'POST',
url: 'http://localhost:8080/restProject/webresources/myresource/appointmentService',
data: JSON.stringify(json),
dataType: 'jsonp',
contentType: "application/json; charset=utf-8",
});
但是我找到405方法未找到错误..无法加载资源:服务器响应状态为405(方法不允许)
注意:当我从Postman工具调用它时它工作正常..任何帮助都非常感谢