蒲公英Datatables i18n弹簧解析器不工作 [英] Dandelion Datatables i18n spring resolver not working
问题描述
我希望它显示具有各种语言支持的标题。
所以我开始使用这个链接。
根据本页建议我的标题显示 ???键???
消息。
我想显示 ID
在列标题中,但它显示 ??? table.header.id ???
。
此链接说
如果钥匙在捆绑包中找不到,那么???消息将显示在列标题中。
但是我已经在 datatables.properties
i18n.locale.resolver = com.github.dandelion.datatables.extras.spring3.i18n.SpringLocaleResolver $
global.i18n。 message.resolver = com.github.dandelion.datatables.extras.spring3.i18n.SpringMessageResolver
还放入 global_en.properties
table.header.id = Id
我也复制了与 global.properties
..但没有工作的相同的文件。
我的jsp文件包含
< datatables:table id =users...>
< datatables:column titleKey =table.header.idproperty =userId/>
< datatables:table />
我的资源文件夹结构是
< img src =https://i.stack.imgur.com/g50NM.jpgalt =res structure>
我应该把 table.header.id = Id
??
需要任何帮助。感谢提前。
注意:我正在使用 AJAX源代码
+ 服务器端处理
。
关于邮件的位置
您似乎以$ code> global 作为基础名称使用Spring ResourceBundleMessageSource
。所以将标题列的所有翻译放在 global _ *。properties
文件中是有意义的。
关于 ???键???
消息
原来是v0.10.0中引入的一个bug。
等待下一个版本发布,有一个解决方法,但只能使用DOM源。
这里遵循以下步骤。
1)而不是使用 titleKey
列属性,您将使用< spring:message>
标签。理论上,他们做的完全相同:在您配置的资源包中查找资源。
首先声明JSP中的Spring taglib:
<%@ taglib prefix =springuri =http://www.springframework.org/tags%>
2)然后,您需要更新Dandelion-Datatables taglib的用法。作为解决方法,您可以使用< datatables:columnHead>
( docs here )标签,以便在列标题中插入任何内容。
只需使用它,如下所示: / p>
< datatables:table id =users... row =user>
...
< datatables:column>
<% - 此标记内的所有内容只会显示在标题列中 - %>
< datatables:columnHead>
< spring:message code =table.header.id/> < ==这将出现在列标题中
< / datatables:columnHead>
<% - 其他所有单元格都将出现 - %>
< c:out value =$ {person.id}/> < ==这将显示在所有列单元格
< / datatables:column>
...
< datatables:table />
有些意见:
- 如果需要访问要迭代的集合的对象,则需要添加
行
表属性,就像使用< c:out>
标签JSTL - 您需要删除
属性
列属性,或< datatables:column>
标签的内容将不被评估
这是很多工作很少回报 - 抱歉,但等待下一个版本被发布,至少它的作品。
添加了新问题。
如果您使用 AJAX源
+ 服务器端处理
。
首先创建一个变量
< spring:message code =table。 header.idvar =titleId/>
并将其添加到
< datatables:column title =$ {titleId}property =userId/>
另外修复可用这里。请升级到 0.10.1-SNAPSHOT
版本。
(StackOverflow要求免责声明:我是蒲公英的作者)
I have recently started to integrate datatables in my spring mvc 4 + hibernate 4 + tiles 3 Project.
I want it to display header with various language support.
So I started with this link.
As per this page suggests my header shows ???key???
message.
I want to display Id
in column header but it is showing ???table.header.id???
.
This link says
If the key cannot be found in the bundle, the ???key??? message will be displayed in the column header.
But I have put following in datatables.properties
i18n.locale.resolver=com.github.dandelion.datatables.extras.spring3.i18n.SpringLocaleResolver
global.i18n.message.resolver=com.github.dandelion.datatables.extras.spring3.i18n.SpringMessageResolver
Also have put in global_en.properties
table.header.id=Id
I also copied same file as global.properties
.. but not worked.
My jsp file contains
<datatables:table id="users" ...>
<datatables:column titleKey="table.header.id" property="userId" />
<datatables:table />
My Resource folder structure is
Where should I put table.header.id=Id
??
Any help is required. Thanks in advance.
Note: I am using AJAX source
+ server-side processing
.
About the location of your messages
You seem to be using the Spring ResourceBundleMessageSource
with global
as a basename. So it makes sense to put all translations of header columns in global_*.properties
files.
About the ???key???
message
It turns out to be a bug introduced in the v0.10.0.
Waiting for the next version to be released, there is a workaround, but working only with DOM sources. Here follows the steps.
1) Instead of using the titleKey
column attribute, you will use the <spring:message>
tag. Theorically, they do the exact same thing: lookup a resource in your configured resource bundle.
Begin by declaring the Spring taglib in your JSP:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
2) Then you need to update the usage of the Dandelion-Datatables taglib. As a workaround, you can use the <datatables:columnHead>
(docs here) tag to insert any content in a column header.
Just use it as follows:
<datatables:table id="users" ... row="user" >
...
<datatables:column>
<%-- Everything inside this tag will only appear in the header column --%>
<datatables:columnHead>
<spring:message code="table.header.id" /> <== this will appear in the column header only
</datatables:columnHead>
<%-- Everything else will appear in all cells --%>
<c:out value="${person.id}" /> <== this will appear in all column cells
</datatables:column>
...
<datatables:table />
Some observations:
- You need to add the
row
table attribute if you need to access the object of the collection being iterated on, as it's done with the<c:out>
tag of the JSTL - You need to remove the
property
column attribute, or the content of the<datatables:column>
tag will not be evaluated
This is a lot of work for very little return - sorry for that - but waiting for the next version to be released, at least it works. A new issue has been added.
If you are using AJAX source
+ server-side processing
.
Make a variable first
<spring:message code="table.header.id" var="titleId" />
and added it in
<datatables:column title="${titleId}" property="userId" />
Also a fix is available here. Kindly upgrade to 0.10.1-SNAPSHOT
version.
(Disclaimer required by StackOverflow: I'm the author of Dandelion)
这篇关于蒲公英Datatables i18n弹簧解析器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!