4
我正在编写Jersey RESTful Web服务。我有以下两种网络方法。使用两个参数实现RESTful Web服务?
@Path("/persons")
public class PersonWS {
private final static Logger logger = LoggerFactory.getLogger(PersonWS.class);
@Autowired
private PersonService personService;
@GET
@Path("/{id}")
@Produces({MediaType.APPLICATION_XML})
public Person fetchPerson(@PathParam("id") Integer id) {
return personService.fetchPerson(id);
}
}
现在我需要再写一个web方法,它需要两个参数,一个是id,一个是name。它应该如下。
public Person fetchPerson(String id, String name){
}
我该如何编写上述方法的Web方法?
谢谢!
蒂姆,在第一种情况下,我是否需要发送请求为:http://somedomain.com/App/persons/2/3?谢谢! – user755806
是的,没错(假设你想让id为2,名字为3)。 –
是啊..有没有什么办法可以像下面那样传递请求? somedomain.com/App/persons/2_somename? – user755806