使用restful方法重定向到页面? [英] Redirecting to a page using restful methods?
本文介绍了使用restful方法重定向到页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个页面,要求用户填写一些表单字段,当他提交时,表单被发送到 Restful 方法,您可以在下面看到:
I've created a page which asks user to fill some form fields and when he submits, the form is sent to a Restful method which you can see below:
@POST
@Path("addUser")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void addUser(@FormParam("username") String username,
@FormParam("password") String password,
@FormParam("id") String id,
@FormParam("group_name") String groupName,
@FormParam("authority_name") String authorityName,
@FormParam("authority_id") String authorityId
)
{
//Something will be done here
}
如何在此函数结束时将用户重定向到(假设)index.jsp?
How can I redirect the user at the end of this function to (let's say) index.jsp?
推荐答案
使用 javax.ws.rs.core.UriBuilder
创建一个 URI,用于映射您想要保留的参数和其他数据.然后使用 Response.temporaryRedirect
将重定向返回给客户端并将您构建的 URI 传递给它.
Create a URI using javax.ws.rs.core.UriBuilder
that maps the parameters and other data you want to preserve. Then use Response.temporaryRedirect
to return a redirect to the client and pass it the URI you’ve built.
这篇关于使用restful方法重定向到页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文