Tomcat 7.0
无法启动以下方法定义
@GET
@Path("/GetSeriesByIndex")
@Produces("application/json")
public String getSeriesListByIndex(@QueryParam("indexCharacter")char indexCharacter){
String allSeriesByIndex = null;
ArrayList<SeriesListDTO> seriesListing=null;
try{
ProjectManager projectManager = new ProjectManager();
seriesListing = projectManager.getSeriesListByIndex(indexCharacter);
Gson gson = new Gson();
allSeriesByIndex = gson.toJson(seriesListing);
}catch(Exception e){
System.out.println(e);
}
return allSeriesByIndex;
}
带有错误消息
com.sun.jersey.api.container.ContainerException: Method, public java.lang.String tv.series.services.webService.TV_Services.getSeriesListByIndex(char), annotated with GET of resource, class tv.series.services.webService.TV_Services, is not recognized as valid Java method annotated with @HttpMethod.
在将indexCharacter
的类型更改为String
时,系统会启动,一切正常。
有人可以解释为什么会这样吗?
我正在使用jersey 1.0.3
个库。也许是那个版本中的一些错误?
由于
答案 0 :(得分:2)
这是泽西岛的api文档:https://jersey.java.net/apidocs/2.7/jersey/javax/ws/rs/QueryParam.html
将字符串转换为char?为什么不使用String?