我正在将一个 Struts 1 应用程序迁移到 Struts2 并尝试最小化所需的代码更改。
我需要知道如何访问ActionForm
Struts2Action
类。下面是我当前的代码,我在尝试访问时遇到了 NPE 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;
}
到达ActionForm
这里的最佳方式是什么?