spring怎么注入失败呢?求解
web.xml文件:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
配置:
XML code
<bean id="userDao" class="cc.user.dao.UserDAO">
</bean>
<bean id="userBo" class="cc.user.bo.UserBo"></bean>
<bean id="userService" class="cc.user.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="userAction" class="cc.user.action.UserAction">
<property name="userService" ref="userService"></property>
<property name="userBo" ref="userBo"></property>
</bean>
java文件:
Java code
public class UserAction extends ActionSupport{
UserBo userBo;
UserService userService;
String result="";
/**
* 验证用户登录
* @return
*/
public String checkUser(){
String i=userService.checkUser(userBo);
result=i;
return SUCCESS;
}
@JSON(serialize=false)
public UserBo getUserBo() {
return userBo;
}
public void setUserBo(UserBo userBo) {
this.userBo = userBo;
}
@JSON(serialize=false)
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
谢谢大家帮忙,看看小弟那里配错了,只有User userservice =new UserService 才能用,也不报错,控制台打印:[color=#FF0000][/color]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=struts]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=struts]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.DefaultActionProxy - Creating an DefaultActionProxy for namespace /user and action name check
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor - intercept '/user/check' {
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor - applied invocation context locale=zh_CN
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor - before Locale=zh_CN
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[cc.user.action.UserAction@ec898a, com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=st