资源拦截器
应用j2ee的filter机制实现对web请求和响应截获,资源拦截器根据当前url以及当前请求的参数自动检查用户凭证和资源的付费情况,自动重定向到登录界面或付费界面或资源的查看界面。用户可以根据自己的业务需要,自定义资源拦截器的支付逻辑。
配置
参见 开发指南-配置过滤器自定义资源拦截器
首先创建一个继承于com.dm.billing.web.filter.Interceptor的类,重载payment方法。然后在web.xml定义你的过滤器。大概java代码如下: public class CustomFilter extends
Interceptor {
protected Payment payment(HttpServletRequest request,
HttpServletResponse response, Account account) {
Payment payment = new Payment();
.....
return payment;
}
} web.xml中的配置如下:
<!-- billing start -->
<filter>
<filter-name>customFilter</filter-name>
<filter-class>com.dm.billing.web.filter.CustomFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>customFilter</filter-name>
<url-pattern>/vip</url-pattern>
</filter-mapping>
<!-- billing end --> 
