0

My RESTful jersey project (dynamic web project) name is "my-jersey".

I have resource class defined following method:

@Path("/my")
public class resource{
     @GET
     @Produces(MediaType.TEXT_PLAIN)
     public String sayPlainTextHello() {
           return "Hello Jersey";
     }
    }

my web.xml:

<servlet-mapping>
    <servlet-name>myjersey</servlet-name>
    <url-pattern>/my/*</url-pattern>
  </servlet-mapping>

When I run my web app in Eclipse. Why the firstly loaded page URL is

http://localhost:8080/my-jersey/
which is an blank.

Question 1. Why it does not display "Hello jersey" ?

Question 2. If I would like the first loaded page is a html file, how and where to specify this? In web.xml ?? How to specify the first load page is myfirstpage.html?

Question 3. Where should I put this myfirstpage.html in the project? Under which directory? (I am using Eclipse dynamic web project to develop the jersey app.)

Mellon
  • 37,586
  • 78
  • 186
  • 264

1 Answers1

0

The @Path annotation provides the path under your application where the resource is located. In this case http://localhost:8080/my-jersey/my would be the path you would have to use to get "Hello Jersey"

Since this is a standard dynamic web app you set it up like any normal app, the fact that you are also using jersey is immaterial.

Put myfirstpage.html in the welcome-file-list section of web.xml and place the file in the WebContent folder.

Mike
  • 831
  • 5
  • 3