我正在尝试将 Map 注入 Grails 控制器。我想将相同的地图注入到许多控制器中,所以想在 resources.groovy 中定义它。
我在网上查看过,但找不到创建简单地图的示例。
在 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">
但是,如果我使用 spring xml 文件,这似乎不适用于 grails。
任何提示表示赞赏。