日期:2014-05-18  浏览次数:20868 次

Exception occurred during processing request: null java.lang.NullPointerExceptio
@SuppressWarnings("serial")
public class RoleAction extends ActionSupport{
private RoleService roleService;
private Yuangong yuanGong;
private List<Yuangong>yuangList = new ArrayList<Yuangong>(0);
private String keyWord;


public RoleService getRoleService() {
return roleService;
}

public void setRoleService(RoleService roleService) {
this.roleService = roleService;
}


public Yuangong getYuanGong() {
return yuanGong;
}

public void setYuanGong(Yuangong yuanGong) {
this.yuanGong = yuanGong;
}

public List<Yuangong> getYuangList() {
return yuangList;
}

public void setYuangList(List<Yuangong> yuangList) {
this.yuangList = yuangList;
}

public String getKeyWord() {
return keyWord;
}

public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}

/**
 * 添加角色
 * @return
 */
public String addRole(){
Yuangong yg = roleService.insertYG(yuanGong);
if(yg!=null){
return "success";
}
return "input";




public interface RoleService {
public Yuangong insertYG(Yuangong yuanGong);
public Yuangong deleteYG(Yuangong yuanGong);
public Yuangong upateYG(Yuangong yuanGong);
public Yuangong findByYgBH(String ygbh);
public List<Yuangong> findByKeyWord(String keyWord);

}


public class RoleServiceImpl implements RoleService {

private RoleDao roleDao;

public void setRoleDao(RoleDao roleDao) {
this.roleDao = roleDao;
}

@Override
public Yuangong insertYG(Yuangong yuanGong) {

return roleDao.insert(yuanGong);
}



public interface RoleDao {

public Yuangong insert(Yuangong yuanGong);
public Yuangong update(Yuangong yuanGong);
public Yuangong delete(Yuangong yuanGong);
public Yuangong findByYgBH(String ygbh);
public List<Yuangong> findByKeyWord(String keyWord);



}


public class RoleDaoImpl implements RoleDao {

/**
 * 插入员工信息
 * @param yuanGong
 * @return
 */
@SuppressWarnings("unused")
@Override
public Yuangong insert(Yuangong yuanGong) {

//创建连接对象
DBMangger dbMangger = new DBMangger();
//SQL语句
String sql = "insert into YuanGong values("+yuanGong.getYgbh()+","+yuanGong.getYgxm()+"," +
""+yuanGong.getYgzh()+","+yuanGong.getYgmm()+","+yuanGong.getYgmm()+","
+yuanGong.getBmbh()+","+yuanGong.getStatus()+",sysdate)";

int i = dbMangger.executeUpdate(sql);
if(i>0){
System.out.println("执行成功");
return yuanGong;
}else{
System.out.println("保存失败");
return null;