I am new to Struts2 and I just realized that whenever I call an action class via a form of a JSP page, I need to have getters and setters for all the parameters in the called action class to access the parameters as shown in below action class:
public class LoginAction extends ActionSupport {
private String userName;
private String password;
public String execute {
System.out.println(this.userName+" "+this.password);
return "success";
}
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;
}
}
However, I also have a POJO class for User which has the same 2 attributes and its getters and setters. Is there a way I can use those getters/setters within my action class? Right now I have getters and setters in both my POJO and my action class. Can anyone help how to eliminate this redundancy?