java - Find and use XML Configuration file with spring -
so have requirement spring filter there urls not need redirected, because introduced responsive design.
i want have xml config this:
<config> <pages> <url>/some/responsive/url/1</url> <url>/some/responsive/url/2</url> ... </pages> </config>
and filter this:
protected void dofilterinternal(httpservletrequest request, httpservletresponse response, filterchain filterchain) throws servletexception, ioexception { if(!isresponsiveurl(request.getservletpath())) { response.sendredirect(externalurl); //redirecto 3th party provide responsiveness return; } filterchain.dofilter(request, response); }
i have resources folder want put xml, can me find way of reading xml , getting url list implement isresponsiveurl
?
can spring find config file automatically, , how?
i don't mind if file isn't xml, .properties file!
the goal this, if need add more pages, can update file without restarting app.
thanks :)
you can create util:list , use @resource inject on attribute:
xml this:
<util:list id="pages"> <value>/some/responsive/url/1</value> <value>/some/responsive/url/2</value> </util:list>
on java, annotate attribute:
@resource(name="pages") private list<string> pages;
obs: don't forget include spring-util.xsd bean definitions.
you can take more information on spring doc site.
i hope i´ve helped
Comments
Post a Comment