在XPages / Java中,有没有更好的方法来将ref的基本URL获取到当前应用程序?
Database.database().reference().child("questionPosts").queryOrderedByKey().observe(.childAdded) { (snapshot) in
if let dict = snapshot.value as? NSDictionary {
//var questionName = dict["name"] as! String
//var created_by = dict["email"] as! String
let questionTitle = dict["name"] as? String
let created_by = dict["email"] as? String
let question = Question(questionName: questionTitle!, created_by: created_by!)
self.questions.append(question)
print(self.questions.count)
}
}
答案 0 :(得分:3)
也许更好一点:
String serverPathNsf = url.getAddress().replace(url.getSiteRelativeAddress(context), "")
url.getAddress()
为您提供nsf + xsp的服务器+路径
http://yourServer/pathTo.nsf/your.xsp
url.getSiteRelativeAddress(context)
为您提供了xsp
/your.xsp
和url.getAddress().replace(url.getSiteRelativeAddress(context), "")
返回nsf的服务器+路径
http://yourServer/pathTo.nsf