spring 注入失败 一直显示java.lang.NullPointerException 30
<beanid="userDao"class="com.dao.UserDao"><propertyname="sessionFactory"ref="sessionFa...
<bean id="userDao" class="com.dao.UserDao">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="userService" class="com.service.UserService">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="request" class="com.action.request">
<property name="userService" ref="userService"></property>
</bean>
action:
package com.action;
import java.util.List;
public class request extends ActionSupport{
private static final long serialVersionUID=1L;
private UserService userService;
private Member user;
public void setUserService(UserService userService)
{
this.userService=userService;
}
public UserService getUserService()
{
return userService;
}
public Member getUser()
{
return user;
}
public void setUser(Member user)
{
this.user=user;
}
public String execute() throws Exception {
try{
Member u=new Member();
u.setUsername(user.getUsername());
u.setPassword(user.getPassword());
u.setEmail(user.getEmail());
userService.saveUser(u);
}
catch(Exception e)
{
e.printStackTrace();
}
return SUCCESS;
}
}
我调过了就是execute里的userService是空的求大神指点!!! 展开
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="userService" class="com.service.UserService">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="request" class="com.action.request">
<property name="userService" ref="userService"></property>
</bean>
action:
package com.action;
import java.util.List;
public class request extends ActionSupport{
private static final long serialVersionUID=1L;
private UserService userService;
private Member user;
public void setUserService(UserService userService)
{
this.userService=userService;
}
public UserService getUserService()
{
return userService;
}
public Member getUser()
{
return user;
}
public void setUser(Member user)
{
this.user=user;
}
public String execute() throws Exception {
try{
Member u=new Member();
u.setUsername(user.getUsername());
u.setPassword(user.getPassword());
u.setEmail(user.getEmail());
userService.saveUser(u);
}
catch(Exception e)
{
e.printStackTrace();
}
return SUCCESS;
}
}
我调过了就是execute里的userService是空的求大神指点!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询