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() 获取属性
基础教程推荐
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
