快速 Alamofire 响应 .jsp

标签 swift jsp swift2 alamofire

我想登录 this link 我的代码是这样的

override func viewDidLoad() {
    super.viewDidLoad()

    let username = "14-032"
    let password = "choi3704"
    let loginParameters = ["id": username as String, "pwd": password as String]

    Alamofire.request(.POST, "http://students.ksa.hs.kr/scmanager/stuweb/index.jsp", parameters: loginParameters, encoding: .JSON).responseJSON{ response in switch response.result {
    case .Success(let JSON):
        let response = JSON as! NSDictionary
        print(response.objectForKey("type"))
    case .Failure(let error):
        print("Request failed with error, \(error)")
        }
    }
}

我得到了

Request failed with error, Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 8." UserInfo={NSDebugDescription=Invalid value around character 8.}

如何解决这个问题?

最佳答案

查看我的other answer了解如何搜索网站以获取信息。您没有使用正确的 URL,也没有使用编码:.JSON

Alamofire.request(.POST, "http://students.ksa.hs.kr/scmanager/stuweb/loginProc.jsp", parameters: loginParameters)
    .responseJSON{ response in
        switch response.result {
        case .Success(let JSON):
            let response = JSON as! NSDictionary
            print(response.objectForKey("type"))
        case .Failure(let error):
            print("Request failed with error, \(error)")
            }
    }

其他一些注意事项:

  • 请勿将真实的用户名和密码发布到 StackOverflow。有些机器人会扫描这些内容。
  • 您的学校使用不安全 HTTP 作为登录网站。他们要求被黑客攻击。

关于快速 Alamofire 响应 .jsp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38609214/

相关文章:

jsp - 在 web-app 中使用 maven 和 eclipse 时抛出异常

ios - 如何在 swift 中为 NSDate 做核心数据获取谓词?我想按月过滤

ios - 收到以下错误 : This application is modifying the autolayout engine from a background thread

ios - 在 UITableView 集合上水平滚动

swift - 参数类型相同但范围不同的重载函数

ios - 如何为循环的每次迭代设置延迟

ios - iOS 上的推特 OAuth

java - 我可以使用什么策略来防止用户发现网站是用什么语言编写的?

mysql - 当我更新我的日期归档时没有更新。我正在使用 mysql 数据库

ios - 在字典中添加多个键和值