方法一:
web.xml配置一个
-
<filter>
-
-
-
-
-
//自己过滤器的名字
-
-
-
-
-
-
</filter>
-
-
<filter-mapping>
-
-
-
</filter-mapping>
方法二:
web.xml配置一个
-
<filter>
-
-
-
-
-
-
-
</filter>
-
-
<filter-mapping>
-
-
-
</filter-mapping>
方法一或者二不同的地方就是在web.xml中的写法不同而已没有太大的区别,配完web.xml之后还要配置applicationContext.xml中的bean。
applicationContext.xml配置:
-
<bean
id="myFilter" class="com.filter.MyFilter"> //指名具体的filter类
-
name="service"> //需要注入的具体参数
-
bean="service"/> -
-
</bean>
-
<bean
id="service" parent="baseTransactionProxy">//这里的service封装了所有对数据库的操作
-
name="target"> -
class="com.maimaiche.service.MaiMaiCheServiceImpl"> -
...... -
-
-
</bean>