开发者

How do I use a variable as the value for the div title attribute

开发者 https://www.devze.com 2023-01-31 11:22 出处:网络
This spring message tag will display the property value of the samples.title.dialog variable on the page:

This spring message tag will display the property value of the samples.title.dialog variable on the page:

<spring:message code="samples.title.dialog" text="samples.title.dialog"/>

This div tag only shows the literal string "samples.titl开发者_如何学编程e.dialog" on the page.

<div id="dialog" title="samples.title.dialog">

How do I use the value of the variable samples.title.dialog as the title of my div tag? When I use the EL expression ${samples.title.dialog} as the title attribute it shows blank on the page.

I'm trying to use a div tag like this:

<div id="dialog" title="${samples.title.dialog}">


Use an EL expression:

<spring:message code="samples.title.dialog" text="${samples.title.dialog}"/>

UPDATE #1:

I think you might be referring to an attribute named samples.title.dialog associated with one of the four scopes: application, request, session or page. Try one of these:

<spring:message code="samples.title.dialog" text="${applicationScope['samples.title.dialog']}"/>
<spring:message code="samples.title.dialog" text="${requestScope['samples.title.dialog']}"/>
<spring:message code="samples.title.dialog" text="${sessionScope['samples.title.dialog']}"/>
<spring:message code="samples.title.dialog" text="${pageScope['samples.title.dialog']}"/>

UPDATE #2:

It looks like you're actually trying to use a value defined in a Spring Internationalization properties file. Check out this Spring Internationalization example and verify that you've done all the steps correctly to wire things up.


<spring:message code="samples.title.dialog" var="i18n_dialog" />
${i18n_dialog}

Note: You can't do this, because samples.title.dialog is a read-only property:

<spring:message code="samples.title.dialog" var="samples.title.dialog" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号