开发者

JSF redirect to other page with parameter

I'm redirecting to another page:

String uri = "../test/planOutput.jsf?job_id=121250";
FacesContext.getCurrent开发者_如何学运维Instance().getExternalContext().dispatch(uri);

It works, but the URL doesn't change, I must see the new URL with the parameter.

What is the solution?


You aren't redirecting the request to a different target at all. You are dispatching the request to a different source. Use ExternalContext#redirect() instead of ExternalContext#dispatch().

FacesContext.getCurrentInstance().getExternalContext().redirect(uri);

A redirect basically instructs the webbrowser to fire a new HTTP request on the given URL. That's also why you see the URL change being reflected in webbrowser's address bar. A dispatch basically instructs the webserver to use a different source for the current request/response. Since this happens internally and does not end up in a new HTTP request, the webbrowser know nothing about the change and the address bar won't be changed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜