社区
Web 开发
帖子详情
ACTION中怎么调用struts.properties的值
leeking888
2011-04-06 02:48:04
在程序的ACTION中怎么调用struts.properties的值??
...全文
187
8
打赏
收藏
ACTION中怎么调用struts.properties的值
在程序的ACTION中怎么调用struts.properties的值??
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
leeking888
2011-04-07
打赏
举报
回复
无解
没有作用
24K純帥
2011-04-06
打赏
举报
回复
<bean:message>
UPC_思念
2011-04-06
打赏
举报
回复
package util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
//单例模式实现读取***.properties文件的内容
public class OVLoadProperties {
// 声明一个自己的实例
private static OVLoadProperties instance = new OVLoadProperties();
final static String fileName = "/config.properties";
// 返回该实例
public static synchronized OVLoadProperties getInstance() {
return instance;
}
// 获取key所对应的值
public String getProperties(String key) {
Properties p = new Properties();
InputStream is = null;
try {
// ***.properties文件放在src目录的下边
is = OVLoadProperties.class.getResourceAsStream(fileName);
if (is == null)
is = new FileInputStream(fileName);
p.load(is);
} catch (Exception e) {
System.out.println("加载文件出错啦!" + e.getMessage());
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}
}
return p.getProperty(key);
}
}
leeking888
2011-04-06
打赏
举报
回复
我就是想在程序中读取里面的配置,不想再次读取文件而已。
然后我的一些配置信息也可以写在里面了
redlotus_lyn
2011-04-06
打赏
举报
回复
用java Properties
问一下,为什么要读那个文件??
july27
2011-04-06
打赏
举报
回复
正好看到书上有的~~~
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
String msg = message.getMessage(locale, "key");
magong
2011-04-06
打赏
举报
回复
但凡properties文件,都可以一样地读,如下:
ResourceBundle resource = ResourceBundle.getBundle("struts");
System.out.println(resource.getString("key"));
amos1989
2011-04-06
打赏
举报
回复
那个。。。不知道你想问啥。。
struts.properties的值的读取是struts去完成的,用于完成struts相关的设置。你想要读他干什么??
当然你也可以读, java中有一个类叫Properties
你查一下API 看下这个类的用法你就知道了。。。或者google一下: java 读取properties
javaWeb天下陶网络商城SSH项目源码
天下陶网络商城主要分为:前台游客浏览、普通用户操作和后台管理3部分。... 四:系统自行修改了
action
请求为html 所以大家不要感到诧异 详细见
struts
.
properties
文件
struts
.
action
.extension=html
详解
struts
2
中
struts
.
properties
Struts
2框架有两个核心配置文件:
struts
.xml和
struts
.
properties
其
中
struts
.xml文件主要负责管理应用
中
的
Action
映射,以及该
Action
包含的Result定义等。除此之外,
Struts
2框架还包含一个
struts
.
properties
文件,该...
struts
.xml和
struts
.
properties
详解
该文件也是
struts
2框架自动加载的文件,在这个文件
中
可以定义一些自己的
action
,interceptor,package等,该文件的package 通常继承
struts
-default包。下面是这个文件的格式。 xml version="1.0" encoding="GBK...
struts
.
properties
配置详解
转自: ...
Struts
2框架有两个核心配置文件,其
中
struts
.xml文件主要负责管理应用
中
的
Action
映射,以及该
Action
包含的Result定义等。除此之外,
Struts
2框架还包含
struts
.
properties
文件,该文件定义
struts
2
中
的
struts
.
properties
详解
struts
.
properties
文件是一个标准的
Properties
文件,该文件包含了系列的key-value对象,每个key就是一个
Struts
2属性,该key对应的value就是一个
Struts
2属性
值
。
struts
.
properties
文件通常放在Web应用的WEB-INF/...
Web 开发
81,092
社区成员
341,717
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章