I want to ask the basic question about Jersey Application.
Is it possible to add and display HTML content in Base URL? If it is possible, how can I implement it?
I use Jersey 2.X Application.
In the usual, I extends the ResourceConfig to implement and set the ApplicationPath as "/api". Besides, I set the resource Path as "test" in Test class and define testResp() with "GET" request.
I use maven to build service.war and deploy on local tomcat, so I can access http://localhost:8080/service/api/test to get result in browser.
But now, I want to display some HTML content in API Base URL: http://localhost:8080/service/api/
For example, I will put some introduction for this service and user can access API Base URL to read.
How can I implement it if possible? Thanks a lot!
Following is the some code example.
Jersey Application sample:
@ApplicationPath("/api")
public class WebApplication extends ResourceConfig {
public WebApplication() {
/**
* register resource, load setting, ...etc
*/
}
}
Resource sample:
@Path("test")
public class Test {
@GET
public Response testResp() {
/**
* impliment the action of http://localhost:8080/service/api/test/
*/
}
}
Aucun commentaire:
Enregistrer un commentaire