Welcome page in REST with Java (JAX-RS) using Jersey

前端 未结 2 601
离开以前
离开以前 2021-01-14 06:18

I am implementing a Restful Web Service using Jersey. I want to show index.jsp as welcome page.

<%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%&         


        
2条回答
  •  死守一世寂寞
    2021-01-14 07:01

    I found an alternative way to do this. instead of using index.jsp, I can use a class like:

    @Path("/")
    public class Hello {
    
        // This method is called if HTML is request
        @GET
        @Produces(MediaType.TEXT_HTML)
        public String sayHtmlHello() {
           return " " + "" + "Rest Page" + ""
              + "

    " + "REST is Working!" + "

    " + " "; }

    In web.xml I do not need to use:

    
            index.jsp
        
    

    And it works fine with:

    /*
    

提交回复
热议问题