I'm just starting out with JavaEE (I'm decently fluent in JavaSE) and am having trouble wrapping my brain around all the new things that are required to make even the simplest of applications. Right now I am trying to use JAX-RS annotations to generate a simple "Hello World" html page in IntelliJ using Glassfish 4. I've searched around for the proper use of these annotations, and it seems like I'm doing it correctly, but I keep getting a 404 no matter where I navigate in localhost. I'm starting to think I'm missing vital components in my code, and I don't know enough about JavaEE to know what I'm missing (perhaps it could be something in the web xml file, which I don't know too much about). Here is the code that I wrote, minus the imports:
@LocalBean
@Stateless
@Path("/hello")
@Produces("text/html")
public class Hello {
@GET
@Path("/world")
public String printHelloWorld() {
return "<html lang=\"en\"><body><h1>Hello, World!</h1></body></html>";
}
}
The server itself is up and running and the application seems to deploy correctly. The default URL that is set up at launch time is "http://localhost:8080/HelloWorld_war_exploded/", so my understanding is that I should be going to http://localhost:8080/HelloWorld_war_exploded/hello/world to display the message.
If anybody could point me in the right direction that would be great. Thanks!
Aucun commentaire:
Enregistrer un commentaire