-
Notifications
You must be signed in to change notification settings - Fork 0
Manual Jersey
Erick Souza edited this page Mar 27, 2017
·
5 revisions
-
Certifique-se de que o arquivo com.sun.jersey.core_1.1.0.0_1-9.jar esteja na biblioteca do projeto.
-
Crie a classe br.gov.dataprev.resources.HelloWorldResource
package br.gov.dataprev.resources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/helloworld")
public class HelloWorldResource {
@GET
@Produces("text/plain")
public String showHelloWorld() {
return "Olá mundo!";
}
}
- Inclua o mapeamento abaixo no arquivo web.xml:
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>br.gov.dataprev.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
- Acesse a url do serviço: http://localhost:7001/projeto-web/rest/helloworld