Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java @PathParam出现错误_Java_Rest_Tomcat_Jersey - Fatal编程技术网

Java @PathParam出现错误

Java @PathParam出现错误,java,rest,tomcat,jersey,Java,Rest,Tomcat,Jersey,我正在使用Jersey,我有以下两种RESTful方法: @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public List<Activity> getAllActivities() { return activityRepository.findAllActivities(); } 在我添加第二种方法之前,一切都很顺利。但是,我的tomcat现在给出了以下错误 org.gl

我正在使用Jersey,我有以下两种RESTful方法:

@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public List<Activity> getAllActivities() {
    return activityRepository.findAllActivities();
}
在我添加第二种方法之前,一切都很顺利。但是,我的tomcat现在给出了以下错误

org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations
有什么线索吗?

你应该使用
@Path(“{activityId}”)
而不是
@PathParam(“{activityId}”)

文件指出

@路径参数

将URI模板参数或包含模板参数的路径段的值绑定到资源方法参数、资源类字段或资源类bean属性

@路径

标识资源类或类方法将为其请求提供服务的URI路径

因此,应该使用
@Path
来定义资源方法将服务的URI路径

org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations