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

fmt标签的使用

首先要在jsp中引入标签库:引入方法为<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

其次引入标签

<fmt:setBundle basename="test" var="paramInfo" />
<fmt:message key="test.login.account.locked.number" var="lockedNumber" bundle="${paramInfo}" />

首先标签<fmt:setBundle>标签用于指定引入哪个properties的信息。这里要引入的是test.properties配置文件的信息。var用来定义参数名。

在<fmt:message>标签中,通过bundle引入在<fmt:setBundle>设置的参数,通过引用<fmt:setBundle>的var值来定义。标签中的key值为引用的properties中参数的key值,var值定义了当前获取到的properties参数名,可以在jsp中通过EL表达式引用。

引用示例:<c:if test="${lockedNumber}">

这里同时使用了<c:if>标签,用于条件判断

国际化

项目中使用了<spring:message>标签来做的国际化。

主要是引入标签库:<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

和引入bean(ResourceBundleMessageSource)

本人前端操作一般般,很多标签都要研究一下才用得起来,所以还是记下来。

猜你喜欢

转载自blog.csdn.net/qq_28600087/article/details/83587516