jsp中读取properties配置文件

将appConfig.properties放在classpath下,也就是src下,文件内容如下:

BAIDU=http://www.baidu.com
GOOGLE=https://www.google.com

在jsp中编写内容如下:

<%@ page language="java" import="java.util.ResourceBundle" %>
<head>
<%ResourceBundle res=ResourceBundle.getBundle("appConfig"); %>
</head>
<body>
<a  href="<%=res.getString("BAIDU")%>" target="view_window">百度</a>
<a  href="<%=res.getString("GOOGLE")%>" target="view_window">谷歌</a>
</body>

猜你喜欢

转载自blog.csdn.net/weixin_44919928/article/details/91656623