-
Apr 12th, 2011, 11:08 AM
#1
GenericFilterBean and init params -> bean props
I have a filter specified in the web.xml with init param as
<init-param>
<param-name>excludePatterns</param-name>
<param-value>/index.jsp,/ping,/login</param-value>
</init-param>
In my Filter's constructor i call
addRequiredProperty("excludePatterns");
and have added methods:
public void setExcludePatterns(String patterns) {
m_excludePatterns = patterns;
}
public String getExcludePatterns() {
return m_excludePatterns;
}
Yet, this bean setter methods are never called.
I see that the addRequiredProperty method is called, but for some reason i can't debug into this code when launched from web logic (perhaps the debugger hasn't attached yet).
What am i doing wrong that these bean property calls are not working?
(The filter is working correctly otherwise)
Using Spring 3.0.5.RELEASE
thanks,
dave
-
Apr 12th, 2011, 09:43 PM
#2
How to get init-params read thru bean properties
In order for the bean property setters to be called for <init-param> the following built-in param needs to be defined, so that the target Filter's init method is called. (which does all the bean reflection).
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
This is ridiculously brain-dead on springs part. Why would i define initial parameters but not want them read.
Anyway, any poor shlub who follows after, might find this helpful.
-
Sep 7th, 2011, 11:22 AM
#3
Thanks for the post! Definitely a time saver! After reading your post, took a quick look at the source code and see why they did it that way; Spring figures that the filter configuration should all be done via bean definition, and not via the web-xml. Interesting choice.
But I agree - it should be smart enough to see that if there are params defined that it reads them.
Tx again!
Eric
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules