Java Resteasy-使用泛型重写方法
现在我正在与resteasy合作。我使用以下结构构建了一个小型Rest应用程序: 控制器类:Java Resteasy-使用泛型重写方法,java,generics,overriding,resteasy,Java,Generics,Overriding,Resteasy,现在我正在与resteasy合作。我使用以下结构构建了一个小型Rest应用程序: 控制器类: @PATH("/rest") public abstract class Controller<T> { @POST public Response post(T ressource){[..]} @PUT public Response put(T ressource){[..]} @DELETE @Path("/{id}") public Response
@PATH("/rest")
public abstract class Controller<T>
{
@POST
public Response post(T ressource){[..]}
@PUT
public Response put(T ressource){[..]}
@DELETE
@Path("/{id}")
public Response delete(@PathParam(value = "id") int id)
@GET
public Response get(){[..]}
}
@PATH(“/rest”)
公共抽象类控制器
{
@职位
公众回应站(T ressource){[…]}
@放
公共响应put(T ressource){[…]}
@删除
@路径(“/{id}”)
公共响应删除(@PathParam(value=“id”)int-id)
@得到
公共响应get(){[…]}
}
ConrollerA类(这只是一个示例):
路径(“/rest/A”)
公共类ControllerA扩展控制器
{
@凌驾
公共回应站(Resourcea ressource){[..]}
[..]
@凌驾
公共响应get(){[…]}
}
我现在就用jetty启动服务器,每次我向“/rest/a”发出POST请求时,服务器都会告诉我,没有这样的方法,但是如果我向路径发出GET请求,那么它就会工作。
如果我用泛型类型重写方法,Jetty或Java会有问题吗
如果我在方法上面写“@POST”注释,它是有效的,但我不想要这种解决方案。我必须在web.xml中进行一些设置,还是java有问题
PATH("/rest/A")
public class ControllerA extends Controller<RessourceA>
{
@Override
public Response post(RessourceA ressource){[..]}
[..]
@Override
public Response get(){[..]}
}