File cfgfile = Resourceutils.getfile ("Classpath:test.txt");
Or
Org.springframework.core.io.Resource Filerource = new Classpathresource ("Test.xml");
Get file: Filerource.getfile ();
Get file stream: Filerource.getinputstream ();
Get to XML: Parse: Example:<myxml> <template id= "index" type= "page" Name= "Home" templatepath= "TEST.FTL" staticpath= " Ii.html "/></myxml>
Document document = new Saxreader (). Read (Filerource.getfile ());
Gets the node with ID test for the template node below myXML
element element = (Element) Document.selectsinglenode ("/myxml/template[@id = ' test ']");
Parse the XML and get the value into the node.
String id = element.attributevalue ("id");
Get temporary files to Java:
System.getproperty ("Java.io.tmpdir"),
Windows is \,unix Yes/
File.separator
A simple test with applicationcontext, get the Bean instance (object) defined in spring. You can use:
ApplicationContext ac = new Classpathxmlapplicationcontext ("Applicationcontext.xml");
Registerdao Registerdao = (Registerdao) ac.getbean ("Registerdao", Registerdao.class);
Introduce the secondary file in the main file:
<import resource= "Classpath*:env/*/applicationcontext.xml"/>
Some properties files can be introduced into the main file as variables in the ApplicationContext
<context:property-placeholder location= "Classpath*:env/default/ecp.properties,
Classpath*:env/default/common.properties,
Classpath*:ecp.properties "
Ignore-resource-not-found= "true" ignore-unresolvable= "true"/>
Get the file resource under Classpath through the Spring tool class, parse the XML