Hello,

I tried a little example on validation with struts2.
Here is the Login.jsp:
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>    
        <head>
                <title>Login</title>
        </head>
        <body>
                <h2>Login</h2>
                <s:form id="login" action="Login">
                        <p><s:textfield label="%{getText('username')}"
name="username" required="true"/></p>
                        <p><s:password label="%{getText('password')}"
name="password" maxlength="255" required="true"/></p>
                        <p><s:submit value="Login"/></p>
                </s:form>
        </body>
</html>

And the Login.java action class:
public class Login extends ActionSupport {
        @Override
        public String execute() throws Exception {
                System.out.println("execute()");
                return SUCCESS;
        }
}

The Login--validation.xml looks like this:
<validators>
  <field name="username">
          <field-validator type="requiredstring">
              <message key="requiredstring"/>
          </field-validator>
  </field>
  <field name="password">
          <field-validator type="requiredstring">
              <message key="requiredstring"/>
          </field-validator>
  </field>
</validators>


And last the struts.xml:
<struts>
        <!-- Include framework defaults (from Struts 2 JAR). -->
        <include file="struts-default.xml" />
        <!-- Configuration for the default package. -->
        <package name="mypackage" extends="struts-default">
                <action name="Login" class="misc.Login">
                        <result name="input">/Login.jsp</result>
                        <result name="success">/Main.jsp</result>
                </action>
        </package>
</struts>


The problem is that I always get back on the Login page although I
entered correct credentials ...
It seems that the result=success never occurs.

Any ideas what's wrong there?


Thanks,
Gerald

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to