-
Notifications
You must be signed in to change notification settings - Fork 0
Manual REST
Erick Nilsen Pereira de Souza edited this page Oct 22, 2015
·
6 revisions
- Crie um Dynamic Web Project
- Crie a classe br.unifor.restful.resources.HelloWorldResource
package br.unifor.restful.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!";
}
}
- Introduza o seguinte mapeamento no arquivo web.xml
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
- Inicie o servidor de aplicação e acesse o link abaixo para ver a saída