Showing the not found 404. Path is correct i think and no errors are showing. Let me help with this.
.java file
@Path("/foods")
public class FoodService {
List<Food> foods;
ArrayList<Food> foodCart = new ArrayList<>();
public FoodService() {
foods = FoodController.getFoodList();
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Food> getFoodList() {
return foods;
}
web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Food Service</display-name>
<servlet>
<servlet-name>food_service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>foodservice</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>food_service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
</web-app>
the link i tried to get value : http://localhost:8080/food_service/rest/foods