You may have another method in the LoginAction class to return login.jsp for login with @SkipValidation
LoginAction.java
public String execute() { if (//username and password correct) { return SUCCESS; //redirect to forums page } else { return LOGIN; } } public void validate() { //validation rule addActionError("Error message"); } @SkipValidation public String loginForm() { return INPUT; }
Now the check will be performed only when the method is executed. First, the request should come to the loginForm method. To do this, a small configuration modification
struts.xml
<action name="login_*" class="community.action.LoginAction" method="{1}"> <result name="success" type="redirect">/forums/list</result> <result name="login">/WEB-INF/login.jsp</result> <result name="input">/WEB-INF/login.jsp</result> </action>
Here the method = "{1}" in the action element will be used to check which request was requested, if nothing is specified in the request, then the execute () method will be called, otherwise the mentioned method will be called. Note that the action name has changed to login _ *
To specify a method name in JSP:
------- <s:submit name="SubmitButton" value="Click To Login" action="login_loginForm"/>
In the view item of the view item above, the action is referred to as login_loginForm. Here login_ stands for the name of the action and loginForm refers to the method to be called. Hope this helps
source share