In Spring 3.0, you can use @value for some files such as Xxx.properties
The following are examples of key-value pairs that are injected into the file:
1 First add in Applicationcontext.xml:
<beans xmlns:util= "Http://www.springframework.org/schema/util"
xsi:schemalocation= "Http://www.springframework.org/schema/util http://www.springframework.org/schema/util/ Spring-util-3.1.xsd ">
</beans>
namespace, and then
2
<util:properties id= "Settings" location= "Web-inf/classes/meta-inf/spring/test.properties"/>
3 Creating Test.properties
Abc=123
4
Import Org.springframework.beans.factory.annotation.Value;
Import Org.springframework.stereotype.Controller;
Import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping ("/admin/images")
@Controller
public class Imageadmincontroller {
Private String Imagedir;
@Value ("#{settings[' Test.abc '}")
public void Setimagedir (String val) {
This.imagedir = val;
}
}
This will inject the value of TEST.ABC into the imagedir.
@value in Spring 3.0