NetBeans Ide을 사용하여 간단한 Restful WebService를 만들려고했습니다.
내 Java EE 버전은 Java EE 7 Web입니다.GlassFish Server에서 JAX-RS 리소스를 찾을 수 없음
이 ContexPath : /DukesAgeService
을 설정하여 새 Java 웹 응용 프로그램을 만들었습니다.
http://localhost:8080/DukesAgeService/
그래서 모든 것이 잘 작동 :
이제 내 응용 프로그램을 실행하는 브라우저에서 내 Index.html
페이지를 표시합니다.
그런 다음 RESTful 웹 서비스 마법사를 사용하여 간단한 리소스를 만들려고했습니다.
package firstcup.webservice;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;
/**
* REST Web Service
*
* @author nolanof
*/
@Path("dukesAge")
public class DukesAgeResource {
@Context
private UriInfo context;
/**
* Creates a new instance of DukesAgeResource
*/
public DukesAgeResource() {
}
/**
* Retrieves representation of an instance of firstcup.webservice.DukesAgeResource
* @return an instance of java.lang.String
*/
@GET
@Produces("text/plain")
public String getText() {
return "hello world";
}
}
그러나이 URL에서 내 응용 프로그램을 실행 : http://localhost:8080/DukesAgeService/dukesAge
내가 404 - 찾을 수 없음 페이지를 얻을
그래서,이 클래스를 만들었습니다.
"/dukesAge"
의 URL을 가진 들어오는 get 요청은 DukesAgeResource
클래스 getText
메서드로 처리됩니다. 뭐가 문제 야? 당신이 서비스를 호출하는 동안 404 오류가 발생하는 이유
감사
프로젝트 폴더 구조와 함께 web.xml 파일도 게시하십시오. –