Table of Contents
기본정보#
- 홈페이지 : https://jersey.dev.java.net/
- API Doc :
애노테이션#
JAX-RS 애노테이션#
- @Path
- @GET
- @Produces
Jersey 애노테이션#
- @Singleton
Jar파일#
![]() |
샘플#
Resource샘플#
package openframework.rest;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import openframework.common.model.Family;
import openframework.common.model.Person;
import com.sun.jersey.spi.resource.Singleton;
@Singleton
@Path("/person")
public class PersonBean {
@GET
@Path("/json")
@Produces("application/json")
public Person getPersonMessageJson() {
return getPerson();
}
@GET
@Path("/xml")
@Produces("text/xml")
public Person getPersonMessageXml() {
return getPerson();
}
@GET
@Path("/text")
@Produces("text/plain")
public Person getPersonMessageTxt() {
return getPerson();
}
private Person getPerson(){
Person person = new Person();
person.setId("123");
person.setName("TEST");
Family family = new Family();
family.setName("ttt");
family.setRelation("형");
List<Family> familyList = new ArrayList<Family>();
familyList.add(family);
person.setFamilyList(familyList);
return person;
}
}
로컬로 요청할 경우 각각의 URL은 다음과 같이 된다.
- http://localhost:8080/person/json
: getPersonMessageJson 메서드 호출
- http://localhost:8080/person/xml
: getPersonMessageXml 메서드 호출
- http://localhost:8080/person/text
: getPersonMessageTxt 메서드 호출
Add new attachment
Only authorized users are allowed to upload new attachments.
List of attachments
| Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
|---|---|---|---|---|---|---|
png |
jersey.png | 1.8 kB | 1 | 16-Dec-2008 15:55 | DongGukLee |


