I am migrating an Struts 1 app to Struts2 and trying to minimize the code changes required.
I need to know how to access the ActionForm
in a Struts2 Action
class. Below is my current code and I am getting NPE when trying to access ActionForm
.
Public class DeptBuildingNewAction extends ActionSupport
implements ServletRequestAware, ServletResponseAware, ModelDriven<DeptBuidingFormBean> {
private HttpServletRequest request;
private HttpServletResponse response;
private DeptBuidingFormBean form;
public void setServletRequest(HttpServletRequest httpServletRequest) {
this.request = httpServletRequest;
}
public void setServletResponse(HttpServletResponse httpServletResponse) {
log.debug("Inside setServletResponse");
this.response = httpServletResponse;
}
public DeptBuidingFormBean getModel() {
log.debug("Inside getForm");
return form;
}
public void setModel(DeptBuidingFormBean form) {
log.debug("Inside setForm");
this.form = form;
}
What is the best way to get the ActionForm
over here?