dimanche 8 novembre 2015

Should REST Services Have non Servlet Content?

I'm doing a Rest Service + Web Site with Wildfly and JAX-RS. My point is to make the Rest Service as some kind of "Controller". I can normally load my index.jsp page, but when it comes to other kind of files (like main.css) it returns 404 HTTP file not found error.

Are those files supposed to be in the same project? Or should I create one Java project for the Rest Service and another for the web site?

My Endpoint looks like this:

@Path("/restservice")
@Produces("text/html; charset=UTF-8")
public class FalkEndpoint {

    @GET
    public String defaultMessage(@Context HttpServletRequest request,@Context HttpServletResponse response){
        return "The server is up! :)";
    }


}

My web.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://ift.tt/nSRXKP" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP">
    <servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>




Aucun commentaire:

Enregistrer un commentaire