You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Juan Jos� Vel�zquez Garcia <ve...@htmlspider.com.br> on 2003/10/16 04:05:37 UTC

Cannot find ActionMappings or ActionFormBeans collection

Hello,

I'm trying to run a sample from the book Struts in Action without success. I getting "Cannot find ActionMappings or ActionFormBeans collection" error. 

If anyone can help me ...

Thanks in advance.

The source code is:

ActionForm.java
===================================
package app;

import org.apache.struts.action.*;

public class RegisterForm extends ActionForm {
  protected String username;
  protected String password1;
  protected String password2;
	 
  public String getPassword1() { return password1; }
  public String getPassword2() { return password2; }
  public String getUsername() { return username; }
  public void setPassword1(String string) { password1 = string; }
  public void setPassword2(String string) { password2 = string; }
  public void setUsername(String string) { username = string; }

}
 
Action.java
==================================

package app;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class RegisterAction extends Action {

  public ActionForward perform(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest req,
    HttpServletResponse res)
    throws IOException, ServletException {
    
    // Cast the form to RegisterForm
    RegisterForm rf = (RegisterForm) form;
    String username = rf.getUsername();
    String password1 = rf.getPassword1();
    String password2 = rf.getPassword2();
    
    if (password1.equals(password2)) {
      try {
        UserDirectory.getInstance().setUser(username,password1);
        return mapping.findForward("success");
      } catch (UserDirectoryException e) {
		return mapping.findForward("failure");
      }
    }
	return mapping.findForward("failure");
    
  }

}

struts-config.xml
=======================================

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
	<form-beans>
		<form-bean name="registerForm" type="app.RegisterForm"/>
	</form-beans>	
	<action-mappings>
      <action    path="/register"
                 type="app.RegisterAction"
                 name="registerForm"
                 input="/register.jsp">
        <forward name="success" path="/success.html"/>
        <forward name="failure" path="/failure.html"/>
      </action>
	</action-mappings>
</struts-config>


register.jsp
=====================

<%@ taglib uri="/WEB-INF/lib/struts-html.tld" prefix="form" %>

<form:form action="/register">
 UserName:<form:text property="username"/><br>
 enter password:<form:password property="password1"/><br>
 re-enter password:<form:password property="password2"/><br>
 <form:submit value="Register"/>
</form:form>




+----------------------------------------+
      Juan Jose Velazquez Garcia 
    Information System Developer 
        www.htmlspider.com.br
+----------------------------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org