使用Javaservlets和JSP的服务器客户端通信

时间:2018-04-24 07:46:54

标签: ajax jsp servlets

我试图通过引用许多资源来了解构建动态Web应用程序的方面。我正在尝试通信并将参数从AJAX传递给java servlet和JSP时遇到问题。 请找到以下代码:

func checkingPostToAddNotifications(userId: String, postId: String, hasUserIdCallback: @escaping (Bool)->Void) {
    //this will get the post id
    print("postId -> \(postId),userId -> \(userId)")
    Api.Post.REF_POSTS.child(postId).child("likes").observe(DataEventType.value, with: { (postCheck) in
        print("postCheck -> \(postCheck)")
        if let notificationValue = postCheck.value as? NSDictionary{

            print("notificationValue -> \(notificationValue.allKeys)")
            let keys = notificationValue.flatMap(){$0.0 as? String}
            print("keys => \(keys)")
            let hasUserId = keys.contains(userId);
            print("hasUserId -> \(hasUserId)")

            //if your id is in we send notification to post.uid
            //send notification if true
            hasUserIdCallback(hasUserId)

        } else {
            //if not we remove from uid
            hasUserIdCallback(false)
        }
    })
}

值实际上在booknames_list中。但我想在单独的页面中显示值。你能指导我实现同样的目标吗?

谢谢

0 个答案:

没有答案