-3
저는 휴식 API를 처음 사용합니다.나머지 API 매개 변수를 가져 오는 방법은 무엇입니까?
매개 변수로 문자열을 취한 다음 부울을 반환하는 API를 만들어야합니다.
내 질문은 어떻게 내 API에 해당 문자열을 전달하고 다음 내 API 안에 문자열을 가져 오는 것입니다?
저는 휴식 API를 처음 사용합니다.나머지 API 매개 변수를 가져 오는 방법은 무엇입니까?
매개 변수로 문자열을 취한 다음 부울을 반환하는 API를 만들어야합니다.
내 질문은 어떻게 내 API에 해당 문자열을 전달하고 다음 내 API 안에 문자열을 가져 오는 것입니다?
다음은 쿼리 매개 변수를 제공하지 않을 경우 디폴트 값을 매개 변수에 문자열을 받아이 한 예입니다 :
@Path("business/department/")
public interface DepartmentService {
@GET
@Path("/cs/availability/chat")
@Produces(MediaType.APPLICATION_JSON)
boolean getCustomerServiceAvailability(@QueryParam("type") @DefaultValue("chat") String type);
}
및 구현 클래스는 인터페이스를 구현 아무것도 할 수있다. 이 예에서는 상태가없는 EJB입니다.
@Stateless
public class DepartmentServiceImpl implements DepartmentService {
@Context
private HttpServletRequest request;
private static final Logger LOGGER = Logger.getLogger(DepartmentServiceImpl.class.getName());
@Override
public boolean getCustomerServiceAvailability(String scheduleType) {
RequestInfo reqInfo = new RequestInfo(request, this.getClass(), "getCustomerServiceAvailability");
boolean available;
try {
available = CallBusinessService(scheduleType);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getLocalizedMessage());
throw new ServiceException();
} finally {
reqInfo.logExecutionTime();
}
}
}
값을 API에 전달하는 방법은 여러 가지가 있습니다. URL의 일부로, 쿼리 문자열 매개 변수로 POST 값으로 헤더 값으로 ... – David
제발, 일부 예제 코드 게시 –
내 대답에 응답하거나 연기 하시겠습니까? –