JSF2.2 を使用しており、サーブレット フィルターが構成されています。機能する Filter のコードの一部:
HttpServletResponse response = (HttpServletResponse) resp;
if (userSession == null) {
redirectURLRegular = response.encodeRedirectURL("../login.xhtml?param1=noSession");
redirectURLAjax = response.encodeRedirectURL(request.getContextPath()
+ "/faces/login.xhtml?param1=noSession");
else{
chain.doFilter(req, resp);
return;
if (isAJAXRequest(request)) {
StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<partial-response><redirect url=\"").append(redirectURLAjax)
.append("\"></redirect></partial-response>");
response.setHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml");
PrintWriter pw = response.getWriter();
pw.println(sb.toString());
pw.flush();
} else {
response.sendRedirect(redirectURLRegular);
}
セッションが null リダイレクトの場合、通常と AJAX の両方が発生します。次のページ (login.xhtml、requestScoped) で、Bean のパラメーター値 (param1) を取得できます。
@ManagedProperty("#{param.param1}")
private String param1;
2 番目のパラメーターを追加すると、"../login.xhtml?param1=noSession¶m2=val2"
通常のリクエストは機能します (リダイレクトが発生し、両方のパラメーターが表示されます) が、AJAX リクエストは機能しません (リダイレクトなし、何も起こりません)。ここに Firebug レポートがあります:
XML Parsing Error: not well-formed Location: moz-nullprincipal:{4584d37a-e799-43db-8379-b0451edca95c} Line Number 1, Column 120:
..."/admin/faces/login.xhtml?param1=noSession¶m2=val2"></redirect></partial-r...
...-------------------------------------------------^
これはどのように発生し、AJAX 呼び出しのフィルターで複数のパラメーターを設定するにはどうすればよいですか?