|
6 years ago | |
---|---|---|
.. | ||
CatFilter.java | 6 years ago | |
README.md | 6 years ago |
<filter>
<filter-name>cat-filter</filter-name>
<filter-class>com.dianping.cat.servlet.CatFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cat-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
filter-mapping可以支持匹配规则,比如如下匹配了/r/开头以及/s/开头的path,这样可以让cat-flter仅仅监控部分URL,而不是所有的URL,不过建议是全量URL。
<filter-mapping>
<filter-name>cat-filter</filter-name>
<url-pattern>/r/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>cat-filter</filter-name>
<url-pattern>/s/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
HttpServletRequest req = ctx.getHttpServletRequest();
req.setAttribute("cat-page-uri", "myPageName");