手把手教你--jsp读取配置文件(properties文件)--(JSTL的fmt:setBundle和fmt:message读取properties文件)

NX二次开发避坑指南:Block UI Tree控件那些‘诡异’的回调函数到底怎么用? 本文深入解析NX二次开发中Block UI Tree控件的回调函数使用技巧,重点探讨了`OnSelectCallback`和`OnStateChangeCallback`的触发机制差异,以及右键菜单、编辑验证等常见问题的解决方案。通过实际案例和代码示例,帮助开发者避开Tree控件开发中的常见陷阱,提升NXOpen开发效率。 阅读详情

概要

在JavaWeb项目中可以将一些通用的配置放置在.properties文件中,然后在页面中直接读取配置值,在需要对通用配置做变更时即可做到一处修改、处处生效。如:项目中JS中需要异步请求一些域名可以将域名的配置放在配置文件中(properties文件)。

虽然可以用JSP中写java代码来读取properties文件,可是页面整洁度和代码比较多,这里不做演示,建议采用JSTL的<fmt:message>标签来实现起来会更清爽,开始吧。

先来看看要读取的文件search-url.properties(放在resources资源目录下):

search_url=http://search.eyaoshun.com

1.引入JSTL的fmt标签库

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

2.使用<fmt:setBundle>加载properties文件,先将配置文件资源加载到页面如:search-url.properties,起个名称叫searchURL

<!-- basename为不带properties扩展名的文件名,如search-url.properties;var为存储该配置文件的变量名 -->
<fmt:setBundle basename="search-url" var="searchURL" />

3.使用<fmt:message>读取配置值,关键的标签就是它,给读取到的属性值起个名叫search_url

<!-- key为配置文件中的属性名;var为存储该配置值的变量名;bundle为上一步中存储配置文件的变量名 -->
<fmt:message key="search_url" var="search_url" bundle="${searchURL}" /> 

4.使用EL表达式读取配置值

<!-- 上一步中存储配置值的变量名 -->
${search_url}

OK,代码如下

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!-- basename为不带properties扩展名的文件名;var为存储该配置文件的变量名 -->
<fmt:setBundle basename="search-url" var="searchURL" />
<!-- key为配置文件中的属性名;var为存储该配置值的变量名;bundle为上一步中存储配置文件的变量名 -->
<fmt:message key="search_url" var="search_url" bundle="${searchURL}" /> 
<!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">
<title>JSP读取配置文件信息</title>
<script type="text/javascript">var s= '${search_url}';console.log(s)</script>
</head>
<body>
    <div>${search_url}</div>
</body>
</html>

演示如下:

 (完)

optee技术简介 OP-TEE(Open Portable Trusted Execution Environment)是一种开源的可信执行环境(TEE),专为ARM TrustZone架构设计。TEE是一种独立的执行环境,运行在主操作系统之外,为敏感任务提供安全的计算空间,如加密、身份验证、密钥管理等。 阅读详情

相关推荐

Python表白代码:“ 星光月夜烟花皆归你,我也归你”(满天烟花盛开、附番外玫瑰)

导语 "慢品人间烟火色 闲观人间岁月长" ———致自己​​​ ​ ???? 遇见我以后,我们的故事就开始了,愿你历经山河,仍觉得人间值得????。 ​ 星光月夜烟花皆归你,我也归你。关于烟花????大家都​知道多少?有多少表白故事情节都发生在烟 花下,想必木木子????不用说大家也知道叭~​​ 今天这则小短文就是关于烟花的故事!你准备好跟我一起进入烟花的世界了嘛? ​正文 “每一句文案,都有一个故事,你仔细听” ​ 1)环境安装???? 准备好:.

顾木子吖的博客 5万+

在jsp页面中直接读取.properties文件中的配置

在jsp页面中直接读取.properties文件中的配置

qq_42003702的博客 1174

Postman账号

Postman账号一、为什么要注册一个Postm账号二、如何注册Postman账号三、登录账号四、切换账号五、找回账号密码 一、为什么要注册一个Postm账号 注册Postman账号是免费的。当注册并登录一个Postman账号后,用户可以获得一下权限。 (1)同步和备份历史、集合、环境和预置头。 (2)可以轻松处理来自不同机器的多个Postman实例‘ (3)创建集合链接发送给其他开发人员。 当然,不注册也可以使用Postman。 二、如何注册Postman账号 (1)下载、安装Postman应用程序。 (

精益求精,永无止境,永远在路上! 6784

编写一个Java Web项目,实现从properties文件读取数据存储到数据库,并从数据库中读取数据,将结果显示在页面上。启动mysql数据库服务器端,并且创建一个名为studentinfo的数据库

现在是2021年04月26日11:05:08 ,趁今天有空把它搞完. 这里呢采用德鲁伊连接池哈 记得导包 1先上效果图 2上截图 点击删除2 3代码共享 dataOperation.jsp <%-- Created by IntelliJ IDEA. User: zhangxu Date: 2021/4/26 Time: 10:32 上午 To change this template use F...

想找我?: 【编程张无忌的个人空间-哔哩哔哩】 https://b23.tv/0yjNTt2 1781

LPDDR4引脚功能详解:硬件新人必看的设计与调试指南

内存接口是硬件设计中的核心难点,尤其是LPDDR4这类高速动态随机存储技术,引脚繁多且功能复杂。理解其引脚分组逻辑,是进行可靠硬件设计的基础。LPDDR4引脚可划分为时钟使能、命令地址、数据选通、阻抗校准与电源等几大类,其中ZQ引脚外接精密电阻用于校准驱动强度,直接影响信号完整性;CK差分时钟与CKE使能协同控制读写节拍;DQ与DQS构成字节通道。掌握这些引脚的功能与PCB布局约束,能帮助工程师快速定位training失败等问题。本文从工程实践角度,系统梳理LPDDR4引脚定义与调试经验,为硬件新人提供一份

weixin_29191761的博客 252

AI工程化之生成式UI & A2UI(二)

本文介绍了生成式UI框架A2UI的架构设计与核心实现。项目采用AI协作开发模式,通过ATDD(AI驱动的测试驱动开发)确保代码质量。前端SDK基于zustand实现框架无关的状态管理,包含协议解析器、存储管理、渲染器等核心模块。重点展示了基础store构建、A2UI协议解析器的实现过程,包括mock数据准备、测试用例生成和可视化调试。项目采用monorepo管理,利用vite实现高效开发构建。整个系统设计遵循模块化原则,通过清晰的接口定义实现各组件解耦,为后续功能扩展打下基础。

qq_34306228的博客 410

国际化标签 语法用法

8.4.5  标签 标签用于从一个资源包中读取信息并进行格式化输出,它有如下一些使用语法格式: 语法1,没有标签体的情况: messageKey"               [bundle="resourceBundle"]             [var="varName"]             [scope="{page|request|session|applicati

2446

全双工AI语音交互:从原理到实践,构建实时对话系统

语音交互技术正从传统的半双工模式向全双工模式演进,以实现更自然、实时的对话体验。全双工交互的核心原理在于模拟人类电话通话,允许双方同时发送和接收音频流,这需要流式语音识别(Streaming ASR)和实时自然语言理解(Real-time NLU)技术的深度整合。其技术价值在于显著降低交互延迟,支持智能打断(Barge-in),从而提升人机对话的流畅度和自然度。在应用场景上,全双工技术是智能助手、实时翻译、车载语音及无障碍交互等领域的关键突破。本文以微软MAI Realtime等模型为例,探讨如何利用开源技

weixin_33693070的博客 408

在JSP中读取properties文件

配置文件application.properties,内容: version=1.0.0 方法一:使用JSTL标签fmt:message(中文会有乱码问题) 在JSP中添加 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!-- 加载application.properties配置文件 -...

不如一默 1439

计组实验5:cache大小测量与 cache line 大小测量

前言 今天做了实验5,通过 c 语言测 cache 参数。其实按理来说挺简单的,只是我们班没给代码,纯靠自己。听说别的班有给代码 emm 因为《深入理解计算机系统》这本书上面给的代码是 Linux 平台下的,而且需要一个 fcyc2 头文件,可以在 https://github.com/fabiensanglard/CpuCacheMountainViewer 这里找到。 ⚠ 我没有在 Linux 下试过课本上面的代码。。。 我是在 win10 下测试的。。。 所以 。。。 我并不确定我的代码是否正确。

AKGWSB 's blog 1万+

【WRF安装(2025)】服务器移植 WRF 安装环境

【WRF安装(2025)】服务器移植 WRF 安装环境

WW、forever的博客 110

JSP页面直接读取xxx.properties文件中的配置

1.引入jstl中的fmt标签 &amp;amp;amp;amp;amp;lt;%@ taglib prefix=“fmt” uri=“http://java.sun.com/jsp/jstl/fmt”%&amp;amp;amp;amp;amp;gt; 2.使用fmt:setBundle加载properties文件 &amp;amp;amp;amp;amp;lt;!-- iwall为不带properties扩展名的文件名,如iwall.properties;var为存储该配置文

CN_Jack_Joe的博客 2309

微博scheme

微博scheme

qq_42278595的博客 326

Jstl fmt 标签详解

<br />在jstl fmt标签库中的标签一共有 12 个,被分为了两类,分别是:<br />        国际化核心标签: <fmt:setLocale> 、 <fmt:bundle> 、 <fmt:setBundle> 、 <fmt:message> 、 <fmt:param> 、 <fmt:requestEncoding> 。<br />       格式化标签: <fmt:timeZone> 、 <fmt:setTimeZone> 、 <fmt:formatNumber> 、 <fmt:pars

张国鹏的专栏 1241

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Java Web读取properties类型配置文件(在resources下)

对properties类型配置文件进行读写操作

CFL的博客 1559

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

JSP开发中properties文件的使用

一:介绍: properties文件在java开发中使用的比较多,主要是一些配置不希望在程序中写死,而采用 properties文件这样在不同的地方使用只需要修改properties文件而不用修改程序,最平常的 是使用在数据库配置中或信息配置中,在开发多语言版本的时候也很有用处,你不同的语言版本 使用不同的配置文件,这样你就可以不修改程序也不用在程序中在判断,只需要把文件放在 不同的地方...

java开发指南博客 【转载】 458

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jsp 使用properties配置文件方法

问题描述: 大多数常量需要随系统部署而修改,这些参数是不能固定在代码里的,这时候就需要使用properties配置文件了。 1. 建立source folder,文件名随意 2.新建properties文件,以键值对存储 3.读取助兴** * 配置 文件的解析 * @author Administrator * */ public class Propert

不二法门 1217

读取properties配置文件中信息并输出(Properties类)

import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class Demon06 { public static void main(String[] args) { Properties properties=new Properties(); try { properties.load(new FileInputStream("./db

weixin_50870221的博客 713

jstl fmt:message 标签的使用(国际化)

*.jsp 文件 [b][/b] [b][/b] 对应资源文件 *.properties 文件 resource.properties test content=填充括号内的测试内容[b] {0}[/b], {1}, {2} ...

spice 1597

jsp获取properties中的数据-fmt标签

fmt标签的使用 首先要在jsp中引入标签库:引入方法为&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%&gt; 其次引入标签 &lt;fmt:setBundle basename="test" var="paramInfo" /&gt; &lt;fmt:message key="test.

qq_28600087的博客 729

国际化标签 <fmt:bundle>&<fmt:message>的使用

国际化标签 &lt;fmt:bundle&gt;&amp;&lt;fmt:message&gt;的使用   Message.properties文件: name=www.gis520.com #info=欢迎{0}光临! info=\u6b22\u8fce{0}\u5149\u4e34\uff01 ...

weixin_33762321的博客 510

javaWeb 获取properties数据显示案例

1、在resource资源下创建以下目录: 并添加信息。 注意db.properties如何在其他路径下创建可能会存在导出失败,具体参考maven的导出规范。 2、实现类: public class ServletDemo5 extends HelloServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,

qq_50909707的博客 292

fmt:message与fmt:fmt:setBundle

参考文章:http://cainwise.iteye.com/blog/369836 &lt;fmt:message&gt; 标签属性和说明 :     属性 描述 key 资源配置文件的“键”指定 bundle 若使用 &lt;fmt:setBundle&gt; 保存了资源配置文件,该属性就可以从保存的资源配置文件中进行查找 var 将显示信息保存为一个变量 ...

miaoxiongvip的专栏 685

jstl的fmt详解

转自:http://www.web-tag.net/all_9.htm bundle <br /><fmt:bundle> 这签用于资源配置文件的绑定,并在页面中显示出来。<br />示范代码:<br /><fmt:bundle basename="property.test"> <br />更多 bundle 信息 formatDate <br /><fmt:formatDate>  标签用于格式化日期。<br />示范代码:<br /><fmt:formatDate value="${blogEntry

技术人宝哥 1435

web项目中读取properties文件的方法总结

项目结构: 方式一: /*** 传统方式*/private void test1() throws FileNotFoundException, IOException { // FileInputStream in = new FileInputStream("src/test.properties"); // 错误写法1 java项目这么写是正确的 //

lijibo503的专栏 1572

JSP中使用Properties.load()读取配置文件

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34087307的博客 680
上一篇: 手把手教你--jquery chosen插件的使用和API(html下拉框美化)
下一篇: 手把手教你--html、js弹出框插件smoke.js(简单实用弹出框),赠送优化后主题(css)
小流至江河
博客等级 码龄9年 223粉丝 53原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址