- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 g:countrySelect 存储确切的国家/地区名称。例如德国而不是 DEU。它是下拉菜单中的值。下拉文本是德国,但当将其保存到数据库时,它会更改回国家/地区代码。抱歉,如果我有点天真,但我已经搜索了近 3 个小时的解决方案,并且 grails 网站上没有很好的记录。我可以选择任何替代方案,甚至是ajax。只是为了有一种简单的方法来显示国家/地区列表,并且能够存储国家/地区的真实姓名而不是国家/地区代码。谢谢!
最佳答案
您可以使用此函数将 ISO3 国家/地区代码转换为国家/地区名称
def getCountryName(String countryCode) {
Locale.availableLocales.find{it.ISO3Country == countryCode}.displayCountry
}
// Test
println getCountryName('DEU') // prints 'Germany'
如果您想在 GSP 内执行此操作,最好将其作为 TagLib 提供。
关于grails - 克 :countrySelect with full country name as value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2912746/
我正在开发一个启动 MainActivity 的应用程序,并检查用户是否已登录共享首选项,如果他已登录,则将他带到 OfferSelect Activity 。 问题是它停止在 setContentV
我需要根据所选的语言对字段进行排序。在文档中,我找不到任何东西。 http://grails.github.io/grails-doc/2.2.1/ref/Tags/countrySelect.htm
我想使用 g:countrySelect 存储确切的国家/地区名称。例如德国而不是 DEU。它是下拉菜单中的值。下拉文本是德国,但当将其保存到数据库时,它会更改回国家/地区代码。抱歉,如果我有点天真,
在我看来,而不是使用普通的 表单中的字段,我想使用 Grails 的 小部件。 我的问题 ...产生... Afghanistan Albania ... 这意味着,当提交表单
我是一名优秀的程序员,十分优秀!