问题描述
我目前正在为基于Struts 2的应用程序开发语言包.该语言包在属性文件中定义,该属性文件将由前端JSP通过JSTL(FMT标记)进行访问.
I'm currently developing a language pack for an application built on Struts 2. The language pack is defined in a properties file which will be accessed by the frontend JSP via JSTL (FMT tags).
我正在尝试实现类似于字符串格式的功能,即将Struts值插入通过FMT标签检索的句子字符串中.
I'm trying to achieve something like String formatting, i.e. inserting a Struts value into a sentence string retrieved via an FMT tag.
我的属性文件中定义了什么
What's defined in my properties file:
userprofile.link.text = <a href="{0}">Click here</a> to view your profile page.
从JSP方面,
<fmt:message key="userprofile.link.text">
<fmt:param value='/profile/<s:property value="userBean.id"/>'/>
</fmt:message>
但是,链接无法正确呈现.我该如何实现?
However, the link does not render correctly. How do I achieve this ?
推荐答案
-
JSTL使用
${}
(EL);
Struts2 ValueStack通过 StrutsRequestWrapper :
Struts2 ValueStack is exposed to JSTL through the StrutsRequestWrapper:
那么这应该足够了:
<fmt:message key="userprofile.link.text">
<fmt:param value='/profile/${userBean.id}'/>
</fmt:message>
这篇关于评估JSTL标记内的Struts值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!