私はURL
このようにhttp://myDomain/ myWAR/myServletReceiverを持っています
WAR ファイル名やサーブレット レシーバー名をエンド ユーザーに知られたくありません。そこで、この URL を http:/myDomain/ MyAccount のようなものにパーソナライズしようと考えました。
これを実現するために、以下のコードを追加しました。
独自のパッケージを作成しました。以下のコード。
package myOwnPackage
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.ViewHandler;
import javax.faces.context.FacesContext;
import com.sun.facelets.FaceletViewHandler;
public class DynamicViewHandler extends FaceletViewHandler{
public DynamicViewHandler(ViewHandler parent) {
super(parent);
System.out.println("Entered into DynamicViewHandler");
}
public String getActionURL(FacesContext context, String viewId) {
System.out.println("Inside getActionURL");
ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ValueExpression valueExpression = expressionFactory.createValueExpression(context.getELContext(), viewId, String.class);
String result = (String) valueExpression.getValue(context.getELContext());
System.out.println("Value of Result is:" +result);
//I am in the beginning steps and just want to print the value of "result" for each response
return result;
}
}
これで登録しましたfaces-config.xml
<application>
<view-handler>myOwnPackage.FaceletViewHandler</view-handler>
<state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager>
</application>
アプリケーションにアクセスすると、サーブレットがリダイレクトするウェルカム ページは/jsp/html/index.xhtml
.
そのため、ログには以下の値が出力されます。
Entered into DynamicViewHandler
Value of Result is:/jsp/html/index.xhtml
ページ内に他のリンクがありindex.jsf
ます。他のリンクをクリックすると、ブラウザに以下のエラー メッセージが表示されます (に移動する代わりに/jsp/html/secondPage.jsf
)
http:/myDomain/jsp/html/index.html not found (404) error.
私の中に間違いなく欠けているものがありDynamicViewHandler
、それ以上のものfaces-config.xml
があるかもしれません。
ここで他に何が欠けていますか?
jsp/html/secondPage.jsf
また、私はにマッピングしたいと思います/MyAccount