用到的formbean/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.form;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;import com.user.model.User;/**
* MyEclipse Struts
* Creation date: 06-19-2007
*
* XDoclet definition:
* @struts.form name="userForm"
*/
public class UserForm extends ActionForm {
private static final long serialVersionUID=1L;
/** newEmail property */
private String newEmail;/** newUsername property */
private String newUsername;/** newDescription property */
private String newDescription;/** newPassword property */
private String newPassword;/** newTel property */
private String newTel;/** newName property */
private String newName;/** newRole property */
private String newRole;private ArrayList userList;
private String hid;
private User viewUser;
private User updateUser;
/*
* Generated Methods
*//**
* Method reset
* @param mapping
* @param request
*/
/**
* Returns the newEmail.
* @return String
*/
public String getNewEmail() {
return newEmail;
}/**
* Set the newEmail.
* @param newEmail The newEmail to set
*/
public void setNewEmail(String newEmail) {
this.newEmail = newEmail;
}/**
* Returns the newUsername.
* @return String
*/
public String getNewUsername() {
return newUsername;
}/**
* Set the newUsername.
* @param newUsername The newUsername to set
*/
public void setNewUsername(String newUsername) {
this.newUsername = newUsername;
}/**
* Returns the newDescription.
* @return String
*/
public String getNewDescription() {
return newDescription;
}/**
* Set the newDescription.
* @param newDescription The newDescription to set
*/
public void setNewDescription(String newDescription) {
this.newDescription = newDescription;
}/**
* Returns the newPassword.
* @return String
*/
public String getNewPassword() {
return newPassword;
}/**
* Set the newPassword.
* @param newPassword The newPassword to set
*/
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}/**
* Returns the newTel.
* @return String
*/
public String getNewTel() {
return newTel;
}/**
* Set the newTel.
* @param newTel The newTel to set
*/
public void setNewTel(String newTel) {
this.newTel = newTel;
}/**
* Returns the newName.
* @return String
*/
public String getNewName() {
return newName;
}/**
* Set the newName.
* @param newName The newName to set
*/
public void setNewName(String newName) {
this.newName = newName;
}/**
* Returns the newRole.
* @return String
*/
public String getNewRole() {
return newRole;
}/**
* Set the newRole.
* @param newRole The newRole to set
*/
public void setNewRole(String newRole) {
this.newRole = newRole;
}public String getHid() {
return hid;
}public void setHid(String hid) {
this.hid = hid;
}public User getUpdateUser() {
return updateUser;
}public void setUpdateUser(User updateUser) {
this.updateUser = updateUser;
}public ArrayList getUserList() {
return userList;
}public void setUserList(ArrayList userList) {
this.userList = userList;
}public User getViewUser() {
return viewUser;
}public void setViewUser(User viewUser) {
this.viewUser = viewUser;
}
}
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.form;import java.util.ArrayList;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;import com.user.model.User;/**
* MyEclipse Struts
* Creation date: 06-19-2007
*
* XDoclet definition:
* @struts.form name="userForm"
*/
public class UserForm extends ActionForm {
private static final long serialVersionUID=1L;
/** newEmail property */
private String newEmail;/** newUsername property */
private String newUsername;/** newDescription property */
private String newDescription;/** newPassword property */
private String newPassword;/** newTel property */
private String newTel;/** newName property */
private String newName;/** newRole property */
private String newRole;private ArrayList userList;
private String hid;
private User viewUser;
private User updateUser;
/*
* Generated Methods
*//**
* Method reset
* @param mapping
* @param request
*/
/**
* Returns the newEmail.
* @return String
*/
public String getNewEmail() {
return newEmail;
}/**
* Set the newEmail.
* @param newEmail The newEmail to set
*/
public void setNewEmail(String newEmail) {
this.newEmail = newEmail;
}/**
* Returns the newUsername.
* @return String
*/
public String getNewUsername() {
return newUsername;
}/**
* Set the newUsername.
* @param newUsername The newUsername to set
*/
public void setNewUsername(String newUsername) {
this.newUsername = newUsername;
}/**
* Returns the newDescription.
* @return String
*/
public String getNewDescription() {
return newDescription;
}/**
* Set the newDescription.
* @param newDescription The newDescription to set
*/
public void setNewDescription(String newDescription) {
this.newDescription = newDescription;
}/**
* Returns the newPassword.
* @return String
*/
public String getNewPassword() {
return newPassword;
}/**
* Set the newPassword.
* @param newPassword The newPassword to set
*/
public void setNewPassword(String newPassword) {
this.newPassword = newPassword;
}/**
* Returns the newTel.
* @return String
*/
public String getNewTel() {
return newTel;
}/**
* Set the newTel.
* @param newTel The newTel to set
*/
public void setNewTel(String newTel) {
this.newTel = newTel;
}/**
* Returns the newName.
* @return String
*/
public String getNewName() {
return newName;
}/**
* Set the newName.
* @param newName The newName to set
*/
public void setNewName(String newName) {
this.newName = newName;
}/**
* Returns the newRole.
* @return String
*/
public String getNewRole() {
return newRole;
}/**
* Set the newRole.
* @param newRole The newRole to set
*/
public void setNewRole(String newRole) {
this.newRole = newRole;
}public String getHid() {
return hid;
}public void setHid(String hid) {
this.hid = hid;
}public User getUpdateUser() {
return updateUser;
}public void setUpdateUser(User updateUser) {
this.updateUser = updateUser;
}public ArrayList getUserList() {
return userList;
}public void setUserList(ArrayList userList) {
this.userList = userList;
}public User getViewUser() {
return viewUser;
}public void setViewUser(User viewUser) {
this.viewUser = viewUser;
}
}
解决方案 »
- 会spring+quartz做定时功能的请进,帮帮我!
- Hibernate operation: Cannot open connection错误求助
- JDBC数据源和连接池问题
- DAO是什么东东
- 真的很急~jsp简单小问题
- 移植问题
- 请问哪里有针对EJB存取数据的JDBC驱动程序?
- 一个算法的问题!我觉得很难!看哪位大侠能作出来!
- 敢问大虾entity beans 怎么得到另一个entity beans的实体对象,并调用其中的方法?
- 我的一个remote接口的session ejb调用local接口的Entity EJB出现的问题:
- 关于NumberFormatter中的useThousandsSeparator
- Spring里面对DAO的配置的疑问
UserForm userForm=(UserForm)form;
User updateUser=userForm.getUpdateUser();
String username=updateUser.getUsername();
Session session=HibernateSessionFactory.getSession();
Transaction tx=session.beginTransaction();
String sql="select u from User u where u.username='"+username+"'";
Query q=session.createQuery(sql);
ArrayList userList=(ArrayList)q.list();
User user=(User)userList.get(0);
user=updateUser;
session.save(user);
tx.commit();
session.close();
用到的javabean
package com.user.model;public class User {
private int id;
private String username;
private String password;
private String role;
private String name;
private String tel;
private String email;
private String description;public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}}