org.springframework.beans.InvalidPropertyException错误调试

org.springframework.beans.InvalidPropertyException

org.springframework.beans.InvalidPropertyException错误调试,它是我在写Javaweb项目用ssh,时遇到的错误。

出现这个错误主要原因有以下三点:

1、spring的配置文件中的属性变量名要一致。

2、要加入相应的get/set方法。

3、总是报这错误,仔细检查了配置,又没有问题的。原来好像是spring的命名规定第一个大写字母前必须有不少于2个的小写字母。

注意:要格外注意第3点。

最终我找到了我的错误,是出在string的命名规则:我没有写大写字母,全是小写字母。


//在WEB-INF目录下添加spring配置文件applicationContext.xml,用于注入bean等 ,这一步

//里面的applicationContext.xml的spring注入的name=“ ”写错。

在我写的applicationContext.xml里面改错;

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">


<bean id="productAction" class="action.ProductAction" scope="prototype">
<property name="productService" ref="productService"></property>
</bean> 


<bean id="productService" class="service.ProductService">
<property name="productDao" ref="productDao"></property>
</bean>
<bean id="productDao" class="dao.ProductDao">
</bean>


</beans>

测试Struts2和Spring框架是否整合成功 
项目右键->Run As->Run on Server,选择好tomcat容器运行。在浏览器地址栏输入:http:localhost:8080/EmployeeManagementSystem/addProduct.jsp 
如果弹出页面: 

这里写图片描述



我的这个项目运行结果:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值