Roller使用了一些自己的Filter
<!-- 从名称上看,是安全性配置,这个是acegi的配置文件定义 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/security.xml</param-value> </context-param> <!-- 这个就是struts2的配置 ,struts2的Filter要放在最前面。以前项目中,前面放了其他的Filter,造成struts的ValueStack有问题, 页面用struts2标签获取不到元素 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <!-- 要使用struts2上传,要配置这个filter,否则会有一些不知名的错误发生。同样struts的filter放在最前面 --> <!-- This is really strange, but for some reason it's needed to prevent some problems with the file uploads not working intermittently --> <filter> <filter-name>struts2-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> </filter> <!-- acegi安全组件的filter,通过这个进行权限管理 --> <filter> <filter-name>securityFilter</filter-name> <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>org.acegisecurity.util.FilterChainProxy</param-value> </init-param> </filter> <!-- 调试用的Filter,简单的记录request、response等信息,只是作为记录使用, 在正式的使用中可以去掉 --> <filter> <filter-name>DebugFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.DebugFilter</filter-class> </filter> <!-- 在处理结束后,检验一下是否Persistence Session都释放掉了。这个是一个增强的作用,保证处理结束后,Weblogger都被释放掉了 --> <filter> <filter-name>PersistenceSessionFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter</filter-class> </filter> <!-- 检查系统是否准备好了: 有weblogger、数据库安装情况 。这个是对系统运行的基础进行一个检查 --> <filter> <filter-name>BootstrapFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.BootstrapFilter</filter-class> </filter> <!-- 压缩 Most app servers support compression, if yours doesn't then use this one, but don't forget to uncomment the mapping below too. <filter> <filter-name>CompressionFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.CompressionFilter</filter-class> </filter> --> <!-- 请求的Request可能会被一系列的RequestMapper进行检查,可能会隐含的被转到不同的处理地点 ? --> <filter> <filter-name>RequestMappingFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.rendering.filters.RequestMappingFilter</filter-class> </filter> <!-- 一个特殊的初始化Filter,在第一次请求发送的时候,确保有机会获取运行时的一些信息 ? --> <filter> <filter-name>InitFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.InitFilter</filter-class> </filter> <!-- IP限制的Filter : 这个没有什么好说的,禁止某些IP访问。 通过在配置文件中的 ipbanlist.file定义的文件来进行限制,这个文件每一行一个IP地址,通过和request.getRemoteAddr()来进行比较 --> <filter> <filter-name>IPBanFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.IPBanFilter</filter-class> </filter> <!-- 提供安全登陆,确保登陆urls使用https ? --> <filter> <filter-name>SchemeEnforcementFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.SchemeEnforcementFilter</filter-class> </filter> <!-- 所有请求的入口,保证请求用UTF-8编码。这个通常是处理链上的第一个和最后一个。 Roller要求的编码方式是UTF-8,在进行处理之前进行保证 --> <filter> <filter-name>CharEncodingFilter</filter-name> <filter-class>org.apache.roller.weblogger.ui.core.filters.CharEncodingFilter</filter-class> </filter>
Roller自己提供的几个Filter:
1.DebugFilter:
org.apache.roller.weblogger.ui.core.filters.DebugFilter
2.PersistenceSessionFilter:
org.apache.roller.weblogger.ui.core.filters.PersistenceSessionFilter
3. BootstrapFilter :
org.apache.roller.weblogger.ui.core.filters.BootstrapFilter
其实这个也只有在安装的时候管用,正常运行起来就不需要了
4.RequestMappingFilter:
org.apache.roller.weblogger.ui.rendering.filters.RequestMappingFilter
5.InitFilter:
org.apache.roller.weblogger.ui.core.filters.InitFilter
6.IPBanFilter:
org.apache.roller.weblogger.ui.core.filters.IPBanFilter
这个简单,只需要知道IPban的配置,以及配置文件如何写即可
7.SchemeEnforcementFilter
org.apache.roller.weblogger.ui.core.filters.SchemeEnforcementFilter
8.CharEncodingFilter:
org.apache.roller.weblogger.ui.core.filters.CharEncodingFilter
Filter-Mapping如下:
<!-- ****************************************** Filter mappings - order IS important here. ****************************************** --> <!-- NOTE: Wherever "dispatcher" elements are specified in the filter mappings, they are required for Servlet API 2.4 containers, such as Tomcat 5+ and Resin 3+, but should be commented out for Servlet API 2.3 containers, like Tomcat 4.x and Resin 2.x. --> <!-- This filter ensures that the request encoding is set to UTF-8 before any other processing forces request parsing using a default encoding. Note: Any filters preceding this one MUST not cause request parsing. --> <filter-mapping> <filter-name>CharEncodingFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!-- Ip Banning is mapped for comment and trackbacks only. Note: this filter does nothing if an ip ban list is not configured. --> <filter-mapping> <filter-name>IPBanFilter</filter-name> <url-pattern>/roller-ui/rendering/comment/*</url-pattern> <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>IPBanFilter</filter-name> <url-pattern>/roller-ui/rendering/trackback/*</url-pattern> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!-- Scheme enforcement. Only here until we get Acegi scheme enforcement working --> <filter-mapping> <filter-name>SchemeEnforcementFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- Acegi Security filters - controls secure access to different parts of Roller --> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>BootstrapFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- Map everything to the PersistenceSessionFilter. NOTE: Any filters preceding this one MUST NOT use persistence sessions.--> <filter-mapping> <filter-name>PersistenceSessionFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- Init filter. performs some initialization on first request --> <filter-mapping> <filter-name>InitFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- Request mapping. this is what allows the urls to work --> <filter-mapping> <filter-name>RequestMappingFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- Most app servers support compression, if yours doesn't then use this one, but don't forget to uncomment the filter definition above too. <filter-mapping> <filter-name>CompressionFilter</filter-name> <url-pattern>/roller-ui/rendering/page/*</url-pattern> <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>CompressionFilter</filter-name> <url-pattern>/roller-ui/rendering/feed/*</url-pattern> <dispatcher>FORWARD</dispatcher> </filter-mapping> --> <!-- Struts2 --> <filter-mapping> <filter-name>struts2-cleanup</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!-- Context Listeners --> <!-- 控制session的启动和关闭 --> <listener> <listener-class>org.apache.roller.weblogger.ui.core.RollerSession</listener-class> </listener> <!-- 初始化Roller web application/context --> <listener> <listener-class>org.apache.roller.weblogger.ui.core.RollerContext</listener-class> </listener> <!-- Tile的一个监听器 --> <listener> <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class> </listener>