0

如何更改请求中的媒体类型

@Path("/admin")
public interface LoginService extends RestService {

    LoginService INSTANCE = GWT.create(LoginService.class);

    @Path("/login")
    @POST
    @Produces({ MediaType.APPLICATION_JSON })
    @Consumes({ MediaType.APPLICATION_JSON })
    void login(MethodCallback<List<LoginBean>> callback);

}

但在网络中我看到

Request URL:https://localhost:8443/services/v2/admin/login
Request Method:OPTIONS
Status Code:200 
Remote Address:127.0.0.1:8443
Response Headers
allow:POST, OPTIONS
content-length:13
**content-type:text/plain**
date:Mon, 06 Feb 2017 11:15:46 GMT
server:WildFly/10
status:200
x-powered-by:Undertow/1
Request Headers
:authority:localhost:8443
:method:OPTIONS
:path:/services/v2/admin/login
:scheme:https
accept:*/*
accept-encoding:gzip, deflate, lzma, sdch, br
accept-language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
access-control-request-headers:authorization, content-type, x-http-method-override
access-control-request-method:POST
origin:http://127.0.0.1:8888
referer:http://127.0.0.1:8888/AdminConsole.html
user-agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.517

在 RestyGwt 文档中说,但似乎它不起作用(

Configuring the Accept and Content-Type and HTTP Headers
RestyGWT rest calls will automatically set the Accept and Content-Type and HTTP Headers to match the type of data being sent and the type of data expected by the callback. You can override these default values by adding JAX-RS’ @Produces and @Consumes annotations to the method declaration.

https://resty-gwt.github.io/documentation/restygwt-user-guide.html

4

0 回答 0