在我的web.xml
<filter-mapping>
<filter-name>rememberMeCookieFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>mustBeSignedInFilter</filter-name>
<url-pattern>/private/*</url-pattern>
</filter-mapping>
据我所做的测试,如果我转到/private/account.jsp
,必须首先执行mustBeSignedInFilter(from what I could read, it's because the path is more specific)。我需要先记住rememberMeCookieFilter。
我该怎么做?
答案 0 :(得分:1)
您将过滤器映射与servlet映射混淆。与URL匹配的所有过滤器的执行顺序与在web.xml
中指定过滤器映射的顺序相同。因此,交换过滤器映射,它将按预期工作。
<filter-mapping>
<filter-name>mustBeSignedInFilter</filter-name>
<url-pattern>/private/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>rememberMeCookieFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>