在jsp页面使用 java.util.ResourceBundle 来读取配置文件(.properties)文件得到时候报错….
原因:该配置文件未在项目根目录下,即项目的“src”文件夹下
解决方法:将xxxx.properies文件放在src文件夹下
下面附上在jsp页面读取配置文件的代码
<%@ page contentType="text/html; charset=utf-8" language="java"
errorPage="" import="java.util.ResourceBundle"%>
<html>
<head>
<title>test~~~~</title>
<style type="text/css">
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<%ResourceBundle res = ResourceBundle.getBundle("bambooCloud"); %>
<%
// 客户端id
String clientId = res.getString("clientId");
// 密钥
String clientSecret = res.getString("clientSecret");
%>
</script>
<body>
</body>
</html>
附上bambooCloud.properties 的代码
#bamboocloud Auth information
clientId=testAdmin
clientSecret=123456789abcdefg