做黑马的CRM网站SSH整合后一直报错,总是说Userservice中没有添加set方法,但是实际上set方法(自带的set方法生成的是实体对象的set,不是类的set,切记,改完实体对象的名字后也要改set的名字)已经写了,
//注入到service
private UserService userservice ;
public void setUserservice(UserService userservice) {
this.userservice = userservice;
}
找了半天,才发先原来是注入的property标签中的name和实体对象中类不一致导致的,
所以name应该要和实体对象一样,当然如果类和对象名字一样那就没关系。
<!-- 配置Action -->
<bean id="userAction" class="com.ssh.web.action.UserAction" scope="prototype">
<property name="userservice" ref="userService"/>
</bean>
同时ref应该是和ApplicationContext.xml中的其它对应让spring管理的id一致。