Jersey (JSR311-Implementation) & Redirections

前端 未结 1 592
-上瘾入骨i
-上瘾入骨i 2021-02-14 03:19

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

1条回答
  •  深忆病人
    2021-02-14 03:49

    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.

    0 讨论(0)
提交回复
热议问题