admin管理员组

文章数量:1356436

I am working on the Struts2 framework with JSP.

In my samplePrj.properties file, in that

.samplePrj.Successmessage = Saved Successful

is an attribute. I need to use this value in my JSP page, using Struts2.

so how can I get the value of ".samplePrj.Successmessage" in my JSP page.

I am working on the Struts2 framework with JSP.

In my samplePrj.properties file, in that

.samplePrj.Successmessage = Saved Successful

is an attribute. I need to use this value in my JSP page, using Struts2.

so how can I get the value of ".samplePrj.Successmessage" in my JSP page.

Share Improve this question edited Apr 12, 2014 at 17:31 Roman C 1 asked Apr 12, 2014 at 14:57 hKshKs 5162 gold badges7 silver badges20 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Use the text tag

<s:i18n name="samplePrj">
    <s:text name=".samplePrj.Successmessage" />
</s:i18n>

it will load the bundle using i18n tag from samplePrj.properties and print the value from key .samplePrj.Successmessage in it.

or you can use it with getText() but your action class should extend ActionSupport.

<s:property value="getText('.samplePrj.Successmessage')"/>

You can use getText() method to read from properties files.

<s:set var="variable" value="getText('.samplePrj.Successmessage')"/>
<s:if test="myVariable == #variable"> 
  //do what u want
</s:if>

本文标签: javaUsing getText() for the getting property in Struts 2Stack Overflow