I have a problem to feature test a java Servlet Filter.
I short description comes here:
I have import my customize Filter,that extends javax.servlet.Filter, in context root like that:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath*:my-filter.xml"/>
</beans>
And defined my filter in web.xml like that:
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>com.myproject.MyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I have two question:
- I use IntelliJ IDEA as IDE and in my web.xml the following line
<filter-class>com.myproject.MyFilter</filter-class>
it is an error and since this filter is used in other application, I cannot figure out what the problem is. The error is: com.myproject.MyFilter has no default constructor
- how can I do integration test for this servlet. I will use the filter in real and not mock it.
Thanks for any help.
question from:
https://stackoverflow.com/questions/65951720/do-integration-test-for-javax-servlet-filter-filter-class-has-no-default-const 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…