Spring 消息本地化实现(使用注释实现)/使用自定义消息
来源:互联网 发布:日本阶级固化 知乎 编辑:程序博客网 时间:2024/06/08 05:01
配置ResourceBundleMessageSource的Bean,在AppConfig中添加messageSource方法:
import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.Import;import org.springframework.context.support.ResourceBundleMessageSource;import org.springframework.web.servlet.config.annotation.EnableWebMvc;import org.springframework.web.servlet.view.InternalResourceViewResolver;@Configuration@ComponentScan("com")@Import(SecurityConfig.class)@EnableWebMvcpublic class AppConfig { @Bean public InternalResourceViewResolver viewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); resolver.setPrefix("/WEB-INF/secure/"); resolver.setSuffix(".jsp"); return resolver; }<span style="color:#FF6666;"> @Bean public ResourceBundleMessageSource messageSource(){ ResourceBundleMessageSource source=new ResourceBundleMessageSource(); source.setBasename("localization/messages"); source.setUseCodeAsDefaultMessage(true); return source; }</span>}localization/messages位于src/main/recources目录下:
message.properties:
login.failed_message=Login Error,try again!在JSP文件中引用消息:
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %> <!--导入标签库-->....<spring:message code="login.failed_message"/>...
代码:
https://github.com/angleBeibei/SpringSecurity
0 0
- Spring 消息本地化实现(使用注释实现)/使用自定义消息
- 使用 Ajax 实现本地化后的客户端消息验证
- 使用Spring WebSocket实现消息推送
- VC++基础 使用自定义消息实现线程间的通信
- Windows使用自定义消息实现进程之间通信
- MFC使用SendMessage()发送自定义消息实现进程间通信
- MFC使用SendMessage()发送自定义消息实现进程间通信
- MFC使用SendMessage()发送自定义消息实现进程间通信
- MFC使用SendMessage()发送自定义消息实现进程间通信
- MFC使用SendMessage发送自定义消息实现进程间通信
- MFC使用SendMessage()发送自定义消息实现进程间通信
- 使用Websocket实现消息推送(上)
- 使用Websocket实现消息推送(下)
- 使用Websocket实现消息推送(心跳)
- 使用css3实现消息框
- 使用WCF实现消息推送
- 使用Spring JMS轻松实现异步消息传递
- 使用Spring JMS轻松实现异步消息传递
- android studio启动模拟器失败
- VS 2015 OpenGL环境搭建
- 使用ajaxfileupload上传文件
- Windows下使用krpanotools命令行生成全景图
- VS 2015 OpenCV环境搭建
- Spring 消息本地化实现(使用注释实现)/使用自定义消息
- LoadRunner监控Tomcat性能以及tomcat环境部署
- PyGobject(五)布局容器之Button篇——Gtk.Button
- 【9004】&&【7010】最优布线问题
- 配置型软件开发平台
- 一起学Netty(十九)netty源码学习之netty server端源码初读(下)
- 【代码库】删除select元素节点下所有的OPTION节点
- iOS 改变状态栏的字体颜色
- selenium处理页面等待时间的几种方式