Jersey (JSR311-Implementation) & Redirections

▼魔方 西西 提交于 2019-12-21 04:02:50

问题


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().


回答1:


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.



来源:https://stackoverflow.com/questions/3342003/jersey-jsr311-implementation-redirections

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!