weixin_33704234 2018-05-23 16:40 采纳率: 0%
浏览 62

在动态网页中显示404

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

  • 写回答

2条回答 默认 最新

  • weixin_33671935 2018-05-23 18:35
    关注

    Can you try by replacing the display-name and param-value tag values with the package name where class FoodService is located.

    Please refer the link in case of confusions.

    评论

报告相同问题?