不仅可以,而且极度简单,不需要urlrewrite这么厚重的东东,只需创建一个FakeStaticHandler类即可搞定,且看这里:
public class FakeStaticHandler extends Handler {
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
int index = target.lastIndexOf(".html");
if (index != -1) {
target = target.substring(0, index);
}
nextHandler.handle(target, request, response, isHandled);
}
}
将上面的FakeStaticHandler在 YourJFinalConfig 中注册一下就可了:
public void configHandler(Handlers me) {
me.addHandler(new FakeStaticHandler());
}
jfinal 新版本已经提供了 FakeStaticHandler,直接用就行: me.add(new FakeStaticHandler(".html"));