JSP中获取properties文件属性

Posted 愿你安好,愿我晴天

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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中的一个属性名称

以上是关于JSP中获取properties文件属性的主要内容,如果未能解决你的问题,请参考以下文章