springmvc 属性放数据库中解决方法 以及 @Controller 中 使用@vlaue无法注入属性值问题详解
来源:互联网 发布:基因大数据公司 编辑:程序博客网 时间:2024/06/03 09:33
springmvc 属性放数据库中解决方法
自定义一个DatabaseProperties extends PropertyPlaceholderConfigurer implements ApplicationContextAware
重写 mergeProperties 方法 加载数据库的配置 生成新的 Properties 类返回
==》 applicationContext.xml文件中配置 如果要在@controller中使用
@vlaue 注入属性值 就需要在默认的 spring-servlet.xml中也配置以下配置
<!-- 这里不能用${} -->
<bean id="dataBaseProperties" class="com.sfiec.oms.common.DatabaseProperties">
<property name="order" value="2" />
<constructor-arg value="构造参数" />
</bean>
<bean id="dataBaseProperties" class="com.sfiec.oms.common.DatabaseProperties">
<property name="order" value="2" />
<constructor-arg value="构造参数" />
</bean>
@Controller 中 使用@vlaue无法注入属性值问题详解 转载 http://blog.csdn.net/arsenic/article/details/48287745
1,spring-servlet.xml 是一个,我们的controller就在这里,所以这个里面也需要注入属性文件
org.springframework.web.servlet.DispatcherServlet
这里最终是使用WebApplicationContext parent =WebApplicationContextUtils.getWebApplicationContext(getServletContext()); 创建spring容器,代码在FrameworkServlet中
2,applicationContext.xml 是另外一个,也需要注入属性文件
org.springframework.web.context.ContextLoaderListener
在我们的service中可以拿到@Value注入的值,那是因为我们通常都会把获取属性文件定义在applicationContext.xml中,这样在 Controller中是取不到的,必须在spring-servlet.xml 中把获取属性文件再定义一下
1 0
- springmvc 属性放数据库中解决方法 以及 @Controller 中 使用@vlaue无法注入属性值问题详解
- spring mvc Controller中使用@Value无法获取属性值
- spring mvc Controller中使用@Value无法获取属性值
- 使用spring mvc Controller中使用@Value无法获取属性值
- springMVC Controller 参数bean中Date类型属性的赋值问题
- Spring Controller 如何对不同对象中相同的属性名注入不同的值
- servlet中自动注入属性的问题
- spring中使用@RequestBody,对应的bean中属性名大写注入为空的解决方法
- spring中使用@RequestBody,对应的bean中属性名大写注入为空的解决方法
- 设置属性 放于属性窗口中
- 使用s:token action中属性无法得到 问题
- springmvc 在controller 中注入资源文的值
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- SpringMVC配置文件读取其他配置文件中属性VS类中注入配置文件属性
- Struts2中使用OGNL表达式语言访问静态方法和静态属性以及我遇到的问题和解决方法
- Spring中属性注入的几种方式以及复杂属性的注入
- spring中无法读取properties文件中属性的解决方法
- 博客初记
- windows编程第一课
- WIN32API函数CreateProcess创建一个新的进程和它的主线程,新进程运行指定的可执行文件
- 微信小程序开程之路(八)自行部署wafer的一点心得(转载)
- 移动端压缩图片。上传获取图片并压缩。lrz.all.bundle.js插件。 accept="image/*"加载慢的问题
- springmvc 属性放数据库中解决方法 以及 @Controller 中 使用@vlaue无法注入属性值问题详解
- mybatis sql语句的使用
- JAVA学习笔记-数组的初始化方式
- php中使用魔术方法实现aop
- C++
- linux awk命令详解
- 2017.02.24:算法01(深搜)
- elasticsearch 5.2.1安装问题解答
- 2016年开源巨献:来自百度的71款开源项目