您的位置:首页 > 编程语言 > Python开发

python在同一行中显示进度文字

2013-08-01 22:22 288 查看
1. 在ApplicationContext 中定义messageSource
<beans>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>format</value>
<value>exceptions</value>
<value>windows</value>
</list>
</property>
</bean>
</beans>

其中basenames就是指定的多国语言properties 文件前缀format.properties 这些文件在classpath即可,可以在WEB-INF的classes目录下,也可以打在jar包中放在WEB-INF/lib下

2. 编辑properties 文件,推荐eclipse的rbe插件

3. 在java程序中使用多国语言
public static void main(String[] args) {
MessageSource resources = new ClassPathXmlApplicationContext("beans.xml");
String message = resources.getMessage("message", null, "Default", null);
System.out.println(message);
}

通常的做法是把MessageSource 直接注入到bean中,具体参考spring

4. jsp中使用多国语言
3.0中spring拆分了多个包spring.tld文件包含在org.springframework.web.servlet-3.0.X.RELEASE.jar中,web项目要包含此jar否则tld报错
然后在jsp中引入标签库
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

jsp文件中通过
<spring:message code="system.login.error " />

来引用对应的message
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: