package com.eviac.blog.restws;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
@Path("UserInfoService")
public class UserInfo {
@GET
@Path("id/{id}/name/{name}")
@Produces(MediaType.APPLICATION_JSON)
public String userName(@PathParam("id") Integer id, @PathParam("name") String name) {
System.out.println(id+name);
return ("{\"message\":"+1+"}");
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public String userName2(@QueryParam("id") Integer id,@QueryParam("name") String name) {
System.out.println(id+name);
return ("{\"message\":"+2+"}");
}
@POST
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public String ss(@FormParam("id") Integer id,@FormParam("name") String name) {
System.out.println(id+name);
return ("{\"message\":"+3+"}");
}
}
restful接口列子
3星 · 超过75%的资源 需积分: 50 33 浏览量
2016-11-02
16:20:52
上传
评论
收藏 1.16MB ZIP 举报
我的小dn
- 粉丝: 19
- 资源: 20