jsp 获取后端配置文件.properties的某个配置内容

 

如后端有个叫做config.properties的配置文件:

 

sys.img=st_sp

 

jsp中引用的方式是:

 

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String CONTEXT_PATH = request.getContextPath();
    ResourceBundle res = ResourceBundle.getBundle("config");
    String t = res.getString("sys.img");
    String tab_title=new String(t.getBytes("ISO8859-1"),"utf-8");
%>

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="renderer" content="webkit">
    <title>
            <%=tab_title%>
    </title>
</head>
<body>
<div id="app"></div>
</body>
</html>

 

这样就可以获取到配置文件里面对应的配置

posted @ 2019-08-08 12:53  护花使者  Views(1325)  Comments(0Edit  收藏  举报