Struts 块 - 每个块都是异步的吗?
我有使用 struts 的经验,并短暂尝试过使用tiles。 我知道在布局中每个图块都是一个单独的 jsp 页面。 假设我在四个图块上分别点击一个按钮,并且每个图块(间接)调用不同的 Web 服务。 当结果在不同时间出现时,图块是否会异步刷新?
I had experience with struts, and briefly experimented with tiles. I know that within a layout each tile is a separate jsp page. Suppose I hit a button on each of four tiles, and each tile was (indirectly) calling a different web service. Would the tiles refresh asynchronously as results came in at different times?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
磁贴只是一个 html 页面的片段。 除非您手动添加,否则没有 ajax 的概念。 因此:在一页上按 4 个按钮与在任何 html 页面上单击 4 个链接相同。 浏览器将向服务器发送适当的请求。 当服务员回复得很快时,你甚至没有时间按第二个按钮。 当速度足够慢时,第一个请求(浏览器到服务器)将被取消,第二个(第三个、第四个)请求将被发送(并通过按下下一个按钮取消)。
其余的取决于后端实现:在某个时间点,服务器会注意到它无法为 4 个请求中的 3 个发送回数据。 最后(开放)响应中将提供/显示的内容也取决于您的实施。 如果有某个服务器端状态保存 Web 服务响应,则可能会显示所有 4 个结果。 如果一项 Web 服务尚未返回,则可能只会显示 3 个结果和一个旧图块。
Tiles are just fragments of one html page. There's no notion of ajax unless you manually add it. Therefor: Pressing 4 buttons on one page would be the same as clicking 4 links on any html page. The browser will send the appropriate request to the server. When the server answers very quickly, you wouldn't even have time to press the second button. When it's slow enough, the first request (browser to server) would be cancelled and the second (third, fourth) would be sent (and cancelled with the next button pressed).
The rest depends upon the backend implementation: At some point in time the server will notice that it cannot send back data for 3 of the 4 requests. What will be served/displayed in the last (open) response also depends upon your implementation. If there's some server side state holding the web services response, all 4 results might show up. If one web service hasn't returned yet, only 3 results and one old tile might show up.
我认为这取决于后台的代码。 您说这些图块间接调用了 Web 服务。 我认为它会异步刷新,除非您在代码中指定它不这样做。 假设您按下按钮 1,然后按下按钮 2。操作 1 返回,您的代码表示屏幕需要更新并且页面将刷新。 一旦操作 2 返回,您的代码将再次更新屏幕。 我相信这就是它的工作原理,但从未尝试过,我不能确定。
为什么不直接将两个带有按钮的平铺测试页面放在一起并尝试一下。 这应该会给你一个明确的答案。
I think it would depend on the code in the background. You say that the tiles were indirectly calling web services. I would think it would refresh asynchronously unless you specified in your code for it not to do so. Say you push button 1 and then button 2. Action 1 comes back and your code says that the screen needs to be updated and the page will refresh. Once action 2 gets back, your code would again update the screen. I believe this is how it works, but having never tried it, I can't be sure.
Why not just throw together a two tiled test page with buttons and try it out. That should give you a definitive answer.