spring mvc Controller中使用@Value无法获取属性值

http://www.cnblogs.com/xianan87/p/3942010.html

http://blog.csdn.net/cqnaqjy/article/details/51836465



SAXParseException:cvc-elt.1:找不到元素“beans”的声明
引用
一个web工程本地测试通过,maven一个war包放到weblogic下报错,

SAXParseException:cvc-elt.1:找不到元素“beans”的声明
百度了一下不太明白,然后查看自己的applicationContext.xml,发现spring的版本写错了,

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd

其实我的spring包是 3.0的,把这段改了就好了,

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://blog.csdn.net/xiaxiaorui2003/article/details/51850121

在我们的service中可以拿到@Value注入的值,那是因为我们通常都会把获取属性文件定义在applicationContext.xml中,这样在 Controller中是取不到的,必须在dispatcher-servlet.xml 中把获取属性文件再定义一下
http://blog.sina.com.cn/s/blog_c1bea6fb0102wa0x.html

SpringMVC 4.2.2 - Web.xml,Dispatcher-Servlet及ApplicationContext配置笔记
http://blog.csdn.net/chendev1/article/details/50294381

applicationContext.xml和dispatcher-servlet.xml的区别
https://www.cnblogs.com/parryyang/p/5783399.html

Spring的@Value获取不到值的问题
https://www.cnblogs.com/GregZQ/p/8365277.html

猜你喜欢

转载自rd-030.iteye.com/blog/2381918
今日推荐