I have following class and web.xml files. Does spring framework supports jax-rs annotation such as @PATH
, and @PUT
, @Consumes
...etc.
In other word can I use @PATH
instead of @RequestMapping
Java:
import org.springframework.stereotype.Controller;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@Controller
@Path("/register")
public class RegisterServices {
@PUT
@Path("/create")
@Consumes(MediaType.APPLICATION_JSON)
@Produces({"application/json"})
public Response create(@Context HttpServletRequest requestContex,
@HeaderParam("Authorization") String authorization,
String xMsisdn, String param) {}
}
web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
See Question&Answers more detail:os