[英]How to redirect in Asynchronous Servlet?
According to this document , I understand a Request
could be dispatch forward to another servlet in one Asynchronous Servlet which also makes container to call complete()
and trigger another Servlet or JSP automatically. 根据该文档 ,我了解到可以将Request
转发到一个异步Servlet中的另一个Servlet,这也使容器可以调用complete()
并自动触发另一个Servlet或JSP。
But, what if I want to redirect the page under async Servlet? 但是,如果我想在异步Servlet下重定向页面怎么办? Should I call complete()
and response.redirect("")
both? 我应该同时调用complete()
和response.redirect("")
吗? do we have any example of redirection? 我们有重定向的例子吗?
Thanks. 谢谢。
在这种情况下,您可以执行以下操作:使用response.getWriter.write(jsonObject)向客户端(浏览器)提供特定的json响应,并在JavaScript中编写用于更改位置的代码,即location.assign(“ / newPage”)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.