JSF 2.x 对此提出了质疑FileNotFoundException
。我现在没有 Facelets 1.x 游乐场环境,所以我无法为您测试它,但理论上您应该能够通过实现自定义 Facelets 资源解析器来捕获它,通过DefaultResourceResolver
该解析器检查方法中的null
结果resolveUrl()
.
像这样的东西:
import com.sun.facelets.impl.DefaultResourceResolver;
public class CustomResourceResolver extends DefaultResourceResolver {
@Override
public URL resolveUrl(String resource) {
URL url = super.resolveUrl(resource);
if (url == null) {
throw new FacesException(new FileNotFoundException(resource));
// Perhaps add a logging statement instead if this exception
// is after all actually completely swallowed for some reason.
}
return url;
}
}
要让它运行,请在 web.xml 中按如下方式注册它:
<context-param>
<param-name>facelets.RESOURCE_RESOLVER</param-name>
<param-value>com.example.CustomResourceResolver</param-value>
</context-param>