转义方法如下:
native2ascii -encoding gb2312 messages_zh.txt > messages_zh.properties
英文的就不需要转义了。
然后有改变的代码我会帖出来。
message_en_US.properties:
NOT_ALLOW_EMPTY=no empty!
message_zh_CN.properties:
NOT_ALLOW_EMPTY=不能为空
配置信息如下:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:messages/message</value>
</list>
</property>
<property name="useCodeAsDefaultMessage" value="true" />
</bean>
然后,list.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!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>用户信息列表</title>
</head>
<body>
<spring:message code="NOT_ALLOW_EMPTY"/>