Say I have a struts.properties file with a defined value uploads.directory . How can I access that value from an Actioncontext programatically?
相关问题
- Java/Struts2: How to get action name from current
- How to add optgroups to a django ModelMultipleChoi
- NPE in StrutsTestCase after enabling Tiles
- In Tiles,Struts2 java.lang.NoClassDefFoundError: o
- C# How do I create code to set a form back to defa
相关文章
- Does JavaScript allow getters and setters?
- Notice: Undefined property - how do I avoid that m
- Using the typical get set properties in C#… with p
- Struts2 file upload max size
- Mocking nested properties with mock
- Python - What is a lazy property?
- How do I define a Python property *outside* of a c
- Code contracts on auto-implemented properties
You can use getText("some.property.name") which return you the property value
http://struts.apache.org/maven/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html
Create
ActionSupport
Object and by usinggetText()
method ofActionSupport
class.You need to put the values in properties files other than struts.properties for examples
ApplicationResources.properties
ormy.properties
which needs to be in the classpath. struts.properties file is used to load struts specific properties for examplestruts.i18n.encoding=UTF-8
orstruts.devMode = false
etc.The thing you need to do in struts.properties after you create the properties file for your customized messages is you have to add the following property in struts.properties file
If you have more than one custom message property files then you need to add them by separating with comma for example:
Then in your action classes you can access the property values by using
getText('propertyName')
You need to put the my.properties file or my_locale.propeties file in the package that houses your action class.
you can get value from message resource file like this:
you can also get more information, how to get values from
.properties
files in java class or jsp files. for JSP:and
for more information you can go through this link: get info here
Create a resources folder under
src
. In thestruts.xml
file add a constant e.g.,<constant name="struts.custom.i18n.resources" value="global"></constant>
Here global is the name of properties file. Now you will be able to use the properties in the entire application.The welcome.jsp
global.properties
In action class