也就是struts in action第一章的那个例子,编译不过,郁闷啊!!!

解决方案 »

  1.   

    package app;
    import org.apache.struts.action.*;
    public class RegisterForm extends ActionForm {
        protected String username;
        protected String password1;
        protected String password2;
        
        public String getUsername () {return this.username;};
        public String getPassword1() {return this.password1;};
        public String getPassword2() {return this.password2;};
        public void setUsername (String username) {this.username = username;};
        public void setPassword1(String password) {this.password1 = password;};
        public void setPassword2(String password) {this.password2 = password;};
    }package app;
    import org.apache.struts.action.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class RegisterAction extends Action {
        public ActionForward perform (ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res) {
        // ①Cast the form to the RegisterForm
        RegisterForm rf = (RegisterForm) form;
        String username = rf.getUsername();
        String password1 = rf.getPassword1();
        String password2 = rf.getPassword2();
        // ②Apply business logic
        if (password1.equals(password2)) {
            try {
            // ③Return ActionForward for success
            UserDirectory.getInstance().setUser(username,password1);
            return mapping.findForward("success");
            } 
            catch (UserDirectoryException e) {
                return mapping.findForward("failure");
            }
         }
        // ④Return ActionForward for failure
        return mapping.findForward("failure");
       }
    }上面的是RegisterForm.java下面的是RegisterAction.java,都在app目录下,RegisterForm.java编译通过,而RegisterAction.java编译不通过
    烦恼
      

  2.   

    可能是一些目录设置的问题还有就是你的classpath的设置问题!直接这样试一试:
     javac RegisterForm.java RegisterAction.java 来实现同时编译处理!
      

  3.   

    classpath的问题哪,没加那个  .;
      

  4.   

    我也碰到过类似的问题,在classPath里加“.”就行了,这样java编译器就会在本目录中找他需要的类