[英]Servlet 3.0 include html page
I'm trying to achieve the following behavior using the Servlet 3.0 API: 我正在尝试使用Servlet 3.0 API实现以下行为:
This all works except the only way I could send the initial page without getting the response committed is by manually writing using the HttpResponse Writer... 除了我可以发送初始页面而不提交响应的唯一方法之外,所有这些方法都可以使用HttpResponse Writer手动编写...
I was wondering if there is a way of using something similar to RequestDispatcher#include with an html page without running into problems with the AsyncContext. 我想知道是否有一种方法可以将类似RequestDispatcher#include的内容与html页面一起使用,而不会遇到AsyncContext的问题。 Some things I tried until now and didn't work:
我到目前为止尝试过的一些方法没有起作用:
Also, in the Servlet 3.0 spec there are some lines mentioning that dispatching from async servlet to normal servlet is possible but will commit the answer. 另外,在Servlet 3.0规范中,有几行提到从异步servlet到正常servlet的分派是可能的,但将提交答案。 I believe a static html page belongs to this category...
我相信静态的html页面属于该类别...
If you have any ideas of how an elegant include can be done without affecting the ability to still send streamed responses back to the client, please let me know. 如果您有关于如何在不影响将流式响应发送回客户端的能力的前提下进行优雅包含的任何想法,请告诉我。
Thanks 谢谢
use static elements on the page that store data and use requestdispatcher. 使用页面上存储数据的静态元素并使用requestdispatcher。
Or you could also just simply refresh the entire page with such an arrangement using response.setHeader("refresh", "5; URL=officer.html"). 或者,您也可以使用response.setHeader(“ refresh”,“ 5; URL = nzl.html”)以这种安排简单地刷新整个页面。
I really don't understand your need to send multiple requests without the response being committed to a servlet. 我真的不理解您是否需要在不将响应提交到Servlet的情况下发送多个请求。 are you trying to interact with a serving thread multiple times ?
您是否尝试与服务线程多次交互?
一种解决方案(不是唯一的一种):如果它只是一个html页面,则用html编写html页面本身,并对需要提供更新的serrvlet进行ajax调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.