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() 获取属性


基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01