引用官方的原文来解释一下这个问题
What is the Extensions Filter for?
Some MyFaces components do more than include some HTML in the pages. They may need additional support scripts, style. sheets, images, ...
Those resources are included in the MyFaces' jar file and the Extensions Filter add the code and URL needed to provide those resources to the generated HTML.
Some other components, like the file upload component (t:inputFileUpload) need to parse Multipart requests.
The extensions filter handles this as well.
This design has several benefits :
When a component needs a resource, is calls one of the org.apache.myfaces.component.html.util.AddResource methods (for example AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "sarissa.js", context); ).
This method add an attribute to the request so that the filter knows that is must include the given javascript, stylesheet or resource link to the page.
The code for this resource is automatically included in the generated HTML.
The URL for an embedded resource is constructed and always begins by /myfaces/ so that it can be intercepted by the filter when the client need to load the resource.
When the clients fetches the resource, the filter decodes the URL, and serves the proper resource that is embedded in MyFaces' jar.
In your web.xml, map this filter to the path used for the JSF pages (most likely *.jsf) AND to the /faces/* path as in the following example :
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
Under what circumstances am I *required* to use the extensions filter?
If you just use standard JSF component, but don't use any MyFaces' extended component (beginning with t:), then you don't need the Extensions Filter.
However, if you use some of the MyFaces' extended components like t:inputFileUpload, t:inputHTtml, t:inputCalendar, ... then you most likely need to have this filter configured in your webapp.
The filter hasn't any significant impact the response time.
However, as the filter has to cache the whole response in memory before writing it out to the client, it slightly increases the memory usage.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8485249/viewspace-429897/ ,如需转载,请注明出处,否则将追究法律责任。