一、 国际化(语言设置)
-
代码前准备
1.1创建资源文件夹source folder文件夹
https://blog.csdn.net/u014723529/article/details/78050725
1.2新建(几种语言创建几个.properties英文版无需后缀)
-
编写代码
2.1加载语言文件
<fmt:setBundle basename=“applicationMessage” var=“amg”/>
2.2使用语言文件中的变量
<fmt:message key=“age” bundle="${amg}"></fmt:message>
2.3第二种方法
<fmt:bundle basename=“applicationMessage”>
<fmt:message key=“age”></fmt:message>
</fmt:bundle>
2.4设置语言(测试用)
<fmt:setLocale value=“en”></fmt:setLocale> -
国际国家地区语言代码
语言 代码
汉语(Chinese) zh
英语(English) en
德语(German) de
法语(French) fr
日语(Japanese) ja
朝鲜语(Korean) ko
国家(地区) 代码
中国(China) zh
美国(United States) US
英国(Great Britain) GB
加拿大(Canada) CA
德国(Germany) DE
日本(Japan) JP
韩国(Korea) KR
台湾(Taiwan) TW
香港(Hongkong) HK
二、 页面格式化时间
Jsp页面的时间需要从servlet请求传输
<fmt:formatDate pattern=“yyyy-MM-dd HH:mm:ss” value="${dateNow}" />
三、 字符串的处理
定义的字符串
<c:set scope=“page” value=“asd dfg 123” var=“strValue”></c:set>
- <%-- contains --%> contains的JSTL标签写在EL表达式中
strValue中是否包含"ab":${fn:contains(strValue, "ab")}
2. <%-- startWith 和 endWith --%>strValue 以a开头: ${fn:startsWith(strValue,"a")}
strValue 以l结尾: ${fn:endsWith(strValue,"l")}
3. <%--indexOf --%>"f"在strValue中的索引: ${fn:indexOf(strValue,"f") }
4. <%--length --%>strValue 的长度: ${fn:length(strValue)}
5. <%--replace --%>h替换为123: ${fn:replace(strValue,"h","123") }
6. <%--split 用指定符号分割--%>${str}
7. <%--join 用指定符号拼接--%>join: ${fn:join(strs,";")}
8. <%--substring substringBefore substringAfter--%> //提取出索引1-5的字符串substring:${fn:substring(strValue,1,5) }
//提取从开头到第一个A的字符串
substringBefore:${fn:substringBefore(strValue,"A") }
//提取从结尾到第一个A的字符串substringAfter:${fn:substringAfter(strValue,"A") }
9. <%--toLowerCase toUpperCase --%> //全部小写toLowerCase:${fn:toLowerCase(strValue) }
//全部大写toUpperCase:${fn:toUpperCase(strValue) }
10. <%--trim --%> //去空格trim:${fn:trim(strValue) }