salut
je cherche une façon de faire un import dans une propriété
une idée?Code:
1
2
3
4
5
6
7 <bean id="test"> <property name="userName" value="paul"/> <property name="mapDroit"> <import resource="droit.xml"/> </property> </bean>
merci
Version imprimable
salut
je cherche une façon de faire un import dans une propriété
une idée?Code:
1
2
3
4
5
6
7 <bean id="test"> <property name="userName" value="paul"/> <property name="mapDroit"> <import resource="droit.xml"/> </property> </bean>
merci
Dans ton bean tu définies une propriété mapDroit de type org.springframework.core.io.Resource;
puis dans ton applicationContext.xml, il te suffit de faire :
(si ton fichier est dans le classpath)Code:
1
2 <property name="mapDroit" value="classpath:droit.xml"/>
ou
Spring va charger le contenu du fichier xml dans ta propriété mapDroit de type Resource.Code:
1
2 <property name="mapDroit" value="file:C:/.../droit.xml"/>
Tu peux alors appeler la méthode getInputStream() !
Pour plus d'infos, tu peux consulter la référence Spring : http://static.springframework.org/sp...resources.html
ma propriété est de type hashMap...
donc ça fonctionne pas
C'est quoi le contenu de droit.xml ?
le voilà
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <util:map> <entry key="ajouterUtilisateur" value="1"/> <entry key="modifierUtilisateur" value="45"/> </util:map> </beans>