编译报错[[FATAL] A HTTP GET method

74 阅读1分钟

异常信息

[[FATAL] A HTTP GET method, public abstract jakarta.ws.rs.core.Response com.x x x.XxxService.xxxDetail(java.lang.String,boolean), should not consume any form parameter.; 
source='ResourceMethod{httpMethod=GET, consumedTypes=[application/x-www-form-urlencoded], producedTypes=[application/json;charset=UTF-8],

问题原因

@GET
@Path("/order")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
Response xxxDetail(
        @FormParam("aaa") String aaa, @FormParam("bbb") @DefaultValue("true") boolean bbb);

get方法使用了form表单,不符合jakarta规范; 把@FormParam改为@QueryParam, @Consumes(MediaType.APPLICATION_FORM_URLENCODED)改为@Consumes( "application/json; charset=UTF-8")