Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Servlet filters not working in DXP 7.0
Here is our filter code
@Component(
immediate = true,
property = {
"servlet-context-name=",
"servlet-filter-name=Auth Filter",
"url-pattern= /secured/*",
},
service = Filter.class
)
public class AuthFilter implements Filter {}
If I configure this "url-pattern=/*", it works for all URL paths. However, "url-pattern= /secured/*" doesn't work.
Test Case:
localhost:8080/o/user/secured/url1 - Failed
localhost:8080/o/user/secured/- Failed
No error in the log.
Hi,
Using url-pattern="/secured/*" will consider localhost:8080/secured/* pattern,
So in your case you may need to use url-pattern="/o/user/secured/*" for filtering localhost:8080/o/user/secured/url1 pattern.
. It worked. Liferay docs really need to be improved. I was exactly following their docs and it failed.
Thank you for the suggestion for an improvement of LIferay Docs, Vishnu. Would you mind sharing which docs you followed? After all, you're referring to a 5 year old release, and documentation has changed a lot in the past 5 years.
In other words, it might long be documented in a different way.
Or it may not be documented, because the behavior might be assumed: I've never seen any /pattern/* being expected to match /something-else/pattern/something in the java world - that's precisely what wildcards are for.
Powered by Liferay™