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


基础教程推荐
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01