我试图向Grails控制器注入一个Map。我想将相同的地图注入许多控制器,所以想在resources.groovy中定义它。注入一个简单的地图到Grails控制器中
我在网上看过,但找不到创建简单地图的例子。
在Spring MVC我用这样的:
<util:map id="diplomaPermissions">
<entry>
<key>1</key>
<value>Diploma_AQA_Building_And_Construction</value>
</entry>
<entry>
<key>1</key>
<value>Diploma_Edexcel_Building_And_Construction</value>
</entry>
</util:map>
有了这个在我的XML头:
<?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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
但是,这似乎并没有在Grails的工作,如果我用的是春天的XML文件。
任何提示赞赏。
感谢您的回答。我最终将它放在Config.groovy中,但这对我们可能需要定义的其他地图有帮助。再次感谢。 – Matt 2009-10-21 10:49:10