@Test public void testSaveStudent(){ Student student = new Student(); ClassRoom classRoom = new ClassRoom(1, "三年二班"); student.setSid(1); student.setSname("SCOTT"); student.setDate(Calendar.getInstance().getTime()); student.setClsssRoom(classRoom); Response response = target("student").request().post(Entity.entity(student, MediaType.APPLICATION_JSON)); System.out.println(response.getStatus()); System.out.println(response.readEntity(String.class)); System.out.println("----------------------------------------------"); response = target("student").queryParam("callback", "callback").request("application/javascript").post(Entity.entity(student, MediaType.APPLICATION_JSON)); System.out.println(response.getStatus()); System.out.println(response.readEntity(String.class)); }
@POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) public Student saveStudent(Student student){ return student; }
StudentRestService { @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) public Student saveStudent(Student student){ return student; } }
StudentRestService { @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) public Student saveStudent(Student student){ return student; }  }
StudentRestService { @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) public Student saveStudent(Student student){ return student; }  @GET @Path("all") @JSONP(callback="jsonp",queryParam="callback") @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) List<Student> getAll(); @GET @Path("/{id}") @JSONP(callback="jsonp",queryParam="callback") @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student getStudent(@PathParam("id")int id); @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student saveStudent(Student student); @PUT @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student updateStudent(Student student); @DELETE @Path("{id}") @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Response deleteStudent(@PathParam("id")int id,@Context UriInfo uriInfo); }
StudentRestService { @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) public Student saveStudent(Student student){ return student; }  @GET @Path("all") @JSONP(callback="jsonp",queryParam="callback") @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) List<Student> getAll(); @GET @Path("/{id}") @JSONP(callback="jsonp",queryParam="callback") @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student getStudent(@PathParam("id")int id); @POST @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student saveStudent(Student student); @PUT @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Student updateStudent(Student student); @DELETE @Path("{id}") @JSONP(callback="jsonp",queryParam="callback") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON,"application/javascript"}) Response deleteStudent(@PathParam("id")int id,@Context UriInfo uriInfo);  }