从JSP读取配置文件信息

来源:互联网 发布:网络雷人雷语_经典语录 编辑:程序博客网 时间:2024/05/07 03:24

title.properties内容:

title.test = Title For Test

jsp内容:

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8" import="java.util.ResourceBundle"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><% //读取配置文件ResourceBundle res = null;try {res = ResourceBundle.getBundle("title");}catch(Exception e){e.printStackTrace();}%><title><%=res.getString("title.test") %></title></head><body>Hello, World!</body></html>


网站效果:


0 0
原创粉丝点击