Struts2 action的属性 接收值问题
public class UserAction extends ActionSupport { private User user; private UserDao userDao; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String save() { userDao.save(user); return SUCCESS; } public void setUserDao(UserDao userDao) { this.userDao = userDao; }
public class User implements Serializable { private static final long serialVersionUID = -966101986208807450L; private Long userId; private String userName; public User() { } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } }
JSP上写一个hidden<hidden name="user.userId" value="${user.userId}"/>
[解决办法]
不是hibernate的问题.是struts.xml配置与springContext.xml两个关联的配置问题...就是你的userDao没有被注入进对象...把这两个配置文件贴来看下...
[解决办法]
com.ylzinfo.msw.app.domain.User$$EnhancerByCGLIB$$64c0be74
userDao.save(user);org.hibernate.MappingException: Unknown entity
其中user是得对象不认识,debug看看user里面到底是什么