建议使用哪些编程模式传递服务器和客户端之间的标识符/密钥? [英] What are recommended programming patterns for passing identifiers/keys between server and client?

查看:115
本文介绍了建议使用哪些编程模式传递服务器和客户端之间的标识符/密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我需要跟踪的关键或令牌标识被显示及修改浏览器的资源,什么是一些使用的编程模式?

If I need to keep track of a key or token that identifies a resource being displayed and modified in the browser, what are the some of the programming patterns used?

例如,如果我展示电影和转播AJAX调用,为用户检出或审查这些电影,我假设我会嵌入标识符这将被传递回服务器的HTML列表。

For example, if I display a list of movies and hookup ajax calls for users to checkout or review those movies, I'm assuming I would embed the identifier in the html which would then be passed back to the server.

它是不好的做法,使用数据库关键字?它是不好的做法,暴露标识符的HREF?

Is it bad practice to use database keys? Is it bad practice to expose the identifiers in hrefs?

推荐答案

我不认为一个不好的做法,资源标识符暴露给客户。这样做可能会过于复杂系统,没有任何理由。如果数据库的关键,其实是你的实体按键,就可以透明地使用它。

I don't consider a bad practice to expose a resource identifier to the clients. Doing so could overcomplex your system without any reason. If the database key is in fact your entity key, you can use it transparently.

的唯一图案我可以记住在客户端显示和编辑数据是DTO

The only pattern I can remember for displaying and editing data on the client side is DTO.

关于的HREF和你的标识符,一个REST架构甚至会建议你这样做。它是一种常见的做法; )

About the HREFs and your identifiers, a REST architecture would even recommend you to do so. It is a common practice ; )

希望它可以帮助你。

这篇关于建议使用哪些编程模式传递服务器和客户端之间的标识符/密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆