我是angularjs的新手。我想在$ http.put请求发送一个JSON对象如下:
function LoginCtrl($http){
this.login = function(){
var self = this;
self.user = {
username: this.username,
password: this.password
}
$http.put('http://localhost:8086/app/login',self.user).then(function
successCallback(response) {
}, function errorCallback(response) {
})
}
}
我只是想在REST API此JSON对象,该代码是如下: @Path(“/应用程序“) 公共类LoginResource {
public LoginResource() {
}
@PUT
@Path("/login")
@Consumes(MediaType.APPLICATION_JSON)
public Response getUserByName() {
return Response.status(Response.Status.ACCEPTED).build();
}
我需要什么参数传递给这个getUserByName API?我正在使用dropwizard
此外,如果有人可以告诉如何将index.html页面设置为jetty服务器配置中的起始页面。
在后端我使用dropwizard –
那么你应该需要@RequestBody注解。在你的请求对象中,你可以使用@JsonProperty(“name”)来映射事物。 – vilzu
其实我需要在我的webmethod中获取请求负载。有没有办法做到这一点? –