java吧 关注:1,250,585贴子:12,735,798
  • 2回复贴,共1

自己学着搭建SSH框架,遇到点问题,求教!

取消只看楼主收藏回复

我已经去海绵宝宝吧看过了 没找到答案呦~~~~
好心人给看看吧
问题是这样 ----------空指针----------没错 不要笑话我~~
我的action是这样写的
package com.action;
import com.form.UserForm;
import com.opensymphony.xwork2.ActionSupport;
import com.service.CommonService;
public class LoginAction extends ActionSupport {
private UserForm user;
private String username;
private String password;
private CommonService commonService;
public UserForm getUser() {
return user;
}
public void setUser(UserForm user) {
this.user = user;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String execute() {
user = new UserForm();
user.setPassword(password);
user.setUsername(username);
return commonService.CheckUser(user); //这里 看这里commonService 报的空指针
}
}


IP属地:上海1楼2015-04-17 21:45回复
    Spring 的部分配置
    <bean id="loginAction" class="com.action.LoginAction">
    <property name="commonService">
    <ref bean="commonService" />
    </property>
    </bean>
    <bean id="commonDao" class="com.dao.CommonDaoImp">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="commonService" class="com.service.CommonServiceImp">
    <property name="commonDao">
    <ref bean="commonDao" />
    </property>
    </bean>


    IP属地:上海2楼2015-04-17 21:47
    回复
      问题出在哪里呢?


      IP属地:上海3楼2015-04-17 21:48
      回复