Ho cercato di creare un semplice servizio Web riposante, utilizzando NetBeans Ide.
La mia versione Java EE è: Java EE 7 Web.Risorsa JAX-RS non trovata nel server GlassFish
Ho creato una nuova applicazione Web Java, impostando questo ContexPath: /DukesAgeService
.
Ora, in esecuzione la mia domanda, visualizzazione del browser mia pagina Index.html
a:
http://localhost:8080/DukesAgeService/
così, tutto funziona bene.
Quindi, ho provato a creare una risorsa semplice e restful utilizzando la procedura guidata RESTful Web Service.
Così, ho creato questa classe:
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";
}
}
ma in esecuzione la mia domanda, alla url: http://localhost:8080/DukesAgeService/dukesAge
ottengo una pagina 404-non trovato.
Ho verificato che qualsiasi richiesta di ricezione in arrivo con l'url di "/dukesAge"
è stata gestita dal metodo classe getText
. Cosa c'è che non va?
Grazie
Si prega di inviare il file web.xml pure con la struttura delle cartelle di progetto –