java - How to write one action class and action-validation.xml to validate two forms in a two different jsp pages by struts2 -


I am creating a StraSts 2 application that contains the login page and other user details page, I can only create one action class Because of this, I am unable to run the application by adding field validation to both pages in verb-verification.xml. Because the validation.xml validates validity.xml with login page verification validates the remaining field validations (field validation that is related to the user details page).

Therefore, please share your knowledge in struts2 to use an action class with verb-validation.xml for two page (form) validation.

You can do this with your single action class and with it:

Wildcard Mapping

Struts.xml, define such a task:

  & lt; Action Name = "User- *" class = "Dysfunctional" method = "{1}" & gt; & Lt; Name of the result = "input" & gt; / WEB-INF / {1} .jsp & lt; / Results & gt; & Lt; Name of the result = "success" & gt; / WEB-INF / {1} -success.jsp & lt; / Results & gt; & Lt; / Action & gt;  

You can then call the DoSomething action class with one of these two URLs:

  http: //yourapp.com /user-login.action http://yourapp.com/user-details.action  

The result will be that part of the request after the hyphen ("login" or "Description") will replace {1} in your verb definition, therefore the first URL will use the DoSomething.login () method, login.jsp on login or login to success - Go to success.jsp

You define all login () and details () methods DoSomething class.

Validation Rule Association

To associate verification rules with your DoSomething action class, simply upload the .xml file Name DoSomething-validation.xml . Because both user login and user-details request use that class, the rules will run for both.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -