See codes below. I can visit http: // localhost: 8080 / messengerdemo / messages and interact with all the APIs, but every time I go to http: // localhost: 8080 / messengerdemo / profiles I have 404 no error was found. What have I done wrong? I am new and trying to learn knitwear and REST API.
web.xml
<servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>org.learn.rest.messengerdemo.resources</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
Message Resources
@Path("/messages") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class MessageResource { MessageService messageService = new MessageService(); @GET public List<Message> getMessages() { return messageService.getAllMessages(); } }
Profile Resources.
@Path("/profiles") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class ProfileResource { private ProfileService profileservice = new ProfileService(); @GET public List<Profile> getAllProfiles() { return profileservice.getAllProfiles(); } }
source share