JSP中获取properties文件属性

<%@ page contentType="text/html;charset=UTF-8" import="java.util.ResourceBundle"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%
    String path = request.getContextPath();
    // properties 配置文件名称
    ResourceBundle res = ResourceBundle.getBundle("test");
%>
<html>
<head>
<script>
    var name='<%=res.getString("name")%>';
</script>
</head>
<body>
</body>
</html>

test为properties文件 , test.properties  , name 为test中的一个属性名称

posted @ 2017-05-10 17:19  lyhappyday  阅读(2135)  评论(0)    收藏  举报