我开始使用angular 2和typeScript,一切都很棒,但是当我在控制台日志中使用rest api(POST)时,我得到了Response {_body: "", status: 204, statusText: "Ok", headers: Headers, type: 2… },尽管我通过了真正的param登录,这是我的代码
authentification(){
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
// headers.append('Content-Type', 'application/json');
return this.http.post(this._postUrl,JSON.stringify({username:"abc",password:"abc"}),{headers:headers});
}
Run Code Online (Sandbox Code Playgroud)
这是我的网络服务
@POST
@Path("/admin")
@Consumes("application/x-www-form-urlencoded")
public User getDate(@HeaderParam("username")String username,@HeaderParam("password")String password) throws Exception{
try {
String passwordC = AESCrypt.encrypt(password);
User u = userService.login(username, passwordC);
return u;
} catch (Exception e) {
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
我认为我的网络服务参数中的问题在字符串和角度参数中是json,
任何人都可以帮助我,谢谢.
我将开发一个将使用大量复选框的项目.我找到了类似下面的解决方案,但我知道这不是正确的方法.
@IBAction func btn_box(sender: UIButton) {
if (btn_box.selected == true)
{
btn_box.setBackgroundImage(UIImage(named: "box"), forState: UIControlState.Normal)
btn_box.selected = false;
}
else
{
btn_box.setBackgroundImage(UIImage(named: "checkBox"), forState: UIControlState.Normal)
btn_box.selected = true;
}
}
Run Code Online (Sandbox Code Playgroud)
那么,任何人都可以向我展示在我的项目中拥有超过20个复选框的正确方法吗?
我将在表单中使用复选框并用于设置目的.
谢谢.
我花了很多时间试图从Json文件中删除一个项目
这是我的json文件
{
"count": 3,
"data": [
{
"id": "1",
"raison": "ABS",
"email": "abs@abs.com",
"tel": "021269999999"
},
{
"id": "3",
"raison": "PODL",
"email": "abs@abs.com",
"tel": "021269999999"
}, {
"id": "5",
"raison": "dDMS",
"email": "abs@abs.com",
"tel": "021269999999"
}
]
}
Run Code Online (Sandbox Code Playgroud)
在控制器我喜欢这个
$scope.deleteRow = function() {
var _id = 3;
$scope.datas = JSON.stringify($scope.clients["data"]);
$scope.datas.splice(_id,1);
};
Run Code Online (Sandbox Code Playgroud)
所以我给了_id,我想要删除,但我得到这个错误$ scope.datas.splice拼接不是一个功能,我尝试了一个简单的文件,它工作正常["aaa","bob,"ccc"]使用indexof()和拼接,但在这个文件json非:(
如何在JavaScript中知道/比较正确的ID?
所以任何人都帮助我,非常感谢.
javascript ×2
angular ×1
angularjs ×1
checkbox ×1
ios ×1
json ×1
rest ×1
swift ×1
typescript ×1