Using getText() for the getting property in Struts 2(在 Struts 2 中使用 getText() 获取属性)
问题描述
我正在使用 JSP 开发 Struts2 框架.
I am working on the Struts2 framework with JSP.
在我的 samplePrj.properties 文件中,在那个
In my samplePrj.properties file, in that
com.samplePrj.Successmessage = Saved Successful
是一个属性.我需要在我的 JSP 页面中使用这个值,使用 Struts2.
is an attribute. I need to use this value in my JSP page, using Struts2.
那么如何在我的 JSP 页面中获取 "com.samplePrj.Successmessage" 的值.
so how can I get the value of "com.samplePrj.Successmessage" in my JSP page.
推荐答案
使用 文本标签
<s:i18n name="samplePrj">
<s:text name="com.samplePrj.Successmessage" />
</s:i18n>
它将使用 i18n 标签加载包从 samplePrj.properties 并打印其中的键 com.samplePrj.Successmessage 的值.
it will load the bundle using i18n tag from samplePrj.properties and print the value from key com.samplePrj.Successmessage in it.
或者您可以将它与 getText() 一起使用,但您的操作类应该扩展 ActionSupport.
or you can use it with getText() but your action class should extend ActionSupport.
<s:property value="getText('com.samplePrj.Successmessage')"/>
这篇关于在 Struts 2 中使用 getText() 获取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Struts 2 中使用 getText() 获取属性
- Jersey REST 客户端:发布多部分数据 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
