Jersey (JSR311-Implementation) & Redirections

2019-03-25 05:58发布

Is there a way to redirect the user-agent in a Jersey Resource?

In Spring MVC there's the "redirect:"-syntax but I didn't find anything comparable in Jersey's Viewable class. The only method I found working was using HttpServletResponse.sendRedirect().

标签: java rest jersey
1条回答
虎瘦雄心在
2楼-- · 2019-03-25 06:43

You have to return a Response object containing your status code and Location-header. The easiest way is to use javax.ws.rs.core.Response.temporaryRedirect(URI).

When using Viewable you might need to throw a WebApplicationException containing that Response object.

查看更多
登录 后发表回答