客户端/服务器总是分开的!或者他们是吗?

发布于 2024-09-11 08:02:13 字数 261 浏览 10 评论 0原文

令人惊讶的是,在更大的程序员社区中,有多少程序员提出诸如“我如何做 EXTJS 后端?”之类的问题。或者“如何将 jQuery 与 Java 集成?”,不了解客户端和服务器之间的区别。然后我开始思考,是否有框架可以让服务器实际发送 JS 或其他东西到客户端来执行?围绕这些方法的哲学思想是什么?

编辑——澄清一下:

我不是在问这是否可能,我是在问这是一个好的策略还是令人不悦的策略。我不是在问客户端语言是否可以在服务器上运行。我问是否有围绕动态服务动态客户端代码而构建的框架。

Its amazing how many programmers in the greater community of programmers ask questions like "How do I do an EXTJS backend?" or "How do I integrate jQuery with Java?", not understanding the distinction between the client and the server. Then I got to thinking, are there frameworks where the server actually sends JS or something to the client to be executed? What are philosophical thoughts around such approaches?

edit -- to clarify:

im not asking if its possible, I am asking if its a good strategy or frownded upon. I am not asking if client side languages can run on the server. I am asking if there are frameworks that are built around dynamically serving dynamic client side code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乖乖哒 2024-09-18 08:02:13

许多不同的框架都这样做,当您进行 ASP.NET 工作时,您将不断在客户端中看到 POSTBACK 调用,这是由框架生成的,是一个 Javascript 调用。在Java 世界中,大多数JSF 框架都或多或少地做到了这一点。只要你记住“永远不要相信客户”的规则,我认为这没有什么坏处。因此,如果您要在客户端上用 Javascript 进行字段验证,这并不意味着您不必在服务器端进行相同的检查。不久前,我做了一个较大的 Flex 应用程序,作为其中的一部分,我开始创建一个模块,该模块将读取 Hibernate 验证注释并自动在 Actionscript 上创建相同的验证,最后期限在我走得太远之前就终止了,但我确实喜欢这样的想法:能够在后端设置一次验证并在客户端上检查它们,从而节省到服务器的往返过程。

Many different frameworks do this, when you're doing ASP.NET work, you'll constantly be seeing POSTBACK calls in the client, this is generated by the framework and is a Javascript call. In the Java world, most JSF frameworks to this to a greater or lesser extent. I see no harm in this as long as you remember the "never trust the client" rule. So if you are going to do a field validation in Javascript on the client, that does NOT release you from having to do the same check on the server end. I did a largish Flex application not too long ago, and as part of it I started down the road of creating a module that would read Hibernate Validation annotations and automagically create the same validation on the Actionscript, deadlines killed that before I got too far, but I do like the idea of being able to set validations once on the back end and have them checked on the client, saving the round-trip to the server.

无声情话 2024-09-18 08:02:13

向客户端发送 JavaScript 很简单。只需将 script 标记中的 URL 指向动态脚本而不是静态 .js 文件即可。

至于在服务器端运行 JavaScript,Node.js 之类的东西可以让你这样做,尽管它们与浏览器的交互程度不同。

Sending JavaScript to the client is trivial. Simply point the URL in the script tag to a dynamic script instead of a static .js file.

As for running JavaScript on the server side, things like Node.js let you do so, although they don't have the same level of interaction with the browser.

黄昏下泛黄的笔记 2024-09-18 08:02:13

物理障碍肯定是存在的。 HTML/JavaScript/ActionScript 将在客户端空间中运行,并且(实质上)将向后端进行远程过程调用。由于这种裂痕,您将无法消除客户端/服务器架构。

话虽如此,Pierreten 提出了一个很好的观点:Microsoft 的 ASP.NET API 大量使用自动生成的 JavaScript 来与服务器端组件交互。也就是说,您将表单控件添加到项目中,然后将为您生成服务器端和客户端代码。

The physical barrier is definitely there. The HTML/JavaScript/ActionScript will run in the client space and will (in essence) be making remote procedure calls to the back end. Because of this rift you won't be able to eliminate the client/server architecture.

That being said Pierreten makes a good point that Microsoft's ASP.NET API makes heavy use of automatically generated JavaScript to interface with server-side components. That is, you add a form control to your project and both the server and client side code are generated for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文