0
是否可以在struts2中從Action類調用驗證方法? 所以基本上我們要採取行動班控制在struts 1驗證領域等之後,我們可以在下面的方式實現:
我們可以在struts2的action類中調用form validate方法嗎?
@Override
public ActionForward saveUser(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws IOException {
UserForm form = (UserForm) actionForm;
ActionErrors errors = actionForm.validate(mapping, request);
if (!errors.get("password").hasNext() && form.getPassword() != null
...
...
...
爲什麼不呢?你試過了嗎? –
你爲什麼想要?什麼是用例? –
用例如下:在驗證之前,我們需要做一些預處理,比如在會話中設置一些屬性等。然後需要執行驗證,但我們還需要進行一些驗證後處理。因此需要從操作本身調用驗證方法。有什麼建議麼? –