Yenso 2015-09-17 10:43 采纳率: 0%
浏览 1732

ssh框架update()无法获取数据

调试了很久的BUG都解决不了求各位大神解答一下谢谢了
UpdateAction.java
public class UpdateAction extends ActionSupport {

private String userName;
private String userPwd;
private String userRname;
private String userEmail;
private String userCompany;
private String userTel;
private String userFax;
private IEpUserService epUserService;

public UpdateAction() {

}


public UpdateAction(String userName, String userPwd, String userRname,
        String userEmail, String userCompany, String userTel,String userFax
        ) {
    super();
    this.userName = userName;
    this.userPwd = userPwd;
    this.userRname = userRname;
    this.userEmail = userEmail;
    this.userCompany = userCompany;
    this.userTel = userTel;
    this.userFax = userFax;
}


public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getUserPwd() {
    return userPwd;
}

public void setUserPwd(String userPwd) {
    this.userPwd = userPwd;
}

public String getUserRname() {
    return userRname;
}

public void setUserRname(String userRname) {
    this.userRname = userRname;
}

public String getUserEmail() {
    return userEmail;
}

public void setUserEmail(String userEmail) {
    this.userEmail = userEmail;
}

public String getUserCompany() {
    return userCompany;
}

public void setUserCompany(String userCompany) {
    this.userCompany = userCompany;
}

public String getUserTel() {
    return userTel;
}

public void setUserTel(String userTel) {
    this.userTel = userTel;
}

public String getUserFax() {
    return userFax;
}

public void setUserFax(String userFax) {
    this.userFax = userFax;
}

public IEpUserService getEpUserService() {
    return epUserService;
}

public void setEpUserService(IEpUserService epUserService) {
    this.epUserService = epUserService;
}
public String execute() 
{
    EpUser epUser = new EpUser(userName, userPwd, userRname,userEmail, userCompany,userTel,
            userFax,null,null);
    if (epUserService.update(epUser))

        return SUCCESS;
    else
        return ERROR;
}

IEpUserDAO.java
public interface IEpUserDAO 

{
public void update(EpUser persistentInstance);
}

EpUserDAO.java
public void update(EpUser transientInstance) {
log.debug("updating EpUser instance");
try {
getHibernateTemplate().getSessionFactory().openSession().update(transientInstance);
log.debug("update successful");}
catch (RuntimeException re)
{
log.error("update failed", re);
throw re;
}

}

    IEpUserService.java
    public interface IEpUserService 

{
public boolean update(EpUser epUser);
}

EpUserService.java
public class EpUserService implements org.ssh.service.IEpUserService
{

private IEpUserDAO epUserDao;//要进行注入



public IEpUserDAO getEpUserDao() {
    return epUserDao;
}



public void setEpUserDao(IEpUserDAO epUserDao) {
    this.epUserDao = epUserDao;
}
public boolean update(EpUser epUser) {

    epUserDao.update(epUser);
    return true;
}

}

EpUser.java
public EpUser(String userName, String userPwd) {
this.userName = userName;
this.userPwd = userPwd;
}

/** full constructor */
public EpUser(String userName, String userPwd, String userRname,
        String userEmail, String userCompany, String userTel,
        String userFax, Integer userRight,String userDatetime
        ) {
    this.userName = userName;
    this.userPwd = userPwd;
    this.userRname = userRname;
    this.userEmail = userEmail;
    this.userCompany = userCompany;
    this.userTel = userTel;
    this.userFax = userFax;
    this.userRight = userRight;
    this.userDatetime = userDatetime;
    get()和set()省略……

    struts.xml
    <action name="UpdateAction" class="org.ssh.action.UpdateAction">
        <result name="success">/user/updateSuccess.jsp</result>
        <result name="error">/user/editError.jsp</result>
    </action>

    求指点
    前面写了个save方法可以写入数据,但是用update显示无法获取数据来修改
  • 写回答

3条回答 默认 最新

  • threenewbee 2015-09-17 13:33
    关注

    先去掉你的try catch,看下错误信息。把错误信息贴出来。估计是映射有问题。

    评论

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?