LoginSignup
0
1

More than 3 years have passed since last update.

FilterでSpringDIしたかったらDelegatingFilterProxyで実装すべし

Posted at

やること!

  1. Filterクラスの実装
  2. Bean定義 or @Component+ コンポーネントスキャン
  3. web.xmlの実装
LoggingFilter.java
public class LoggingFilter extends OncePerRequestFilter {
    // ....
}

Bean定義

web.xml
<filter>
    <filter-name>loggingFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>loggingFilter</filter-name>
    <url-pattern>/** </url-pattern>
</filter-mapping>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1