从JAX-RS服务发送重定向 [英] Send redirect from a JAX-RS service

查看:447
本文介绍了从JAX-RS服务发送重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将JAX-RS Web服务重定向到另一个网页?

Is it possible to have a JAX-RS web service redirect to another web page?

就像使用Servlet 响应一样。的sendRedirect( HTTP://test/test.html)

Like as you would do with Servlet response.sendRedirect("http://test/test.html").

JAX-RS Web服务本身应该重定向。如果相关,我正在使用RESTEasy。

The JAX-RS web service should itself redirect. I'm using RESTEasy if that's relevant.

推荐答案

是的,你可以在Jersey或任何JAX-RS实现(包括RestEasy)如果您的返回类型是响应(或 HttpServletResponse
https://jersey.github.io/nonav/apidocs/1.5/ jersey / javax / ws / rs / core / Response.html

Yes, you can do this in Jersey or any JAX-RS implementation (including RestEasy) if your return type is a Response (or HttpServletResponse) https://jersey.github.io/nonav/apidocs/1.5/jersey/javax/ws/rs/core/Response.html

您可以使用以下任一项:

You can use either of the following:

Response.temporaryRedirect(URI)







Response.seeOther(URI)

Temporary Redirect返回307状态代码,而See Other返回303.

"Temporary Redirect" returns a 307 status code while "See Other" returns 303.

这篇关于从JAX-RS服务发送重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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