我知道JB里,设置要用到的jar文件我明白怎么弄.project地方可以设置
但是,调用自己写的类就出问题了,就是不认识.
我用了三种方法了,
一就是像设置要用到的jar文件一样,但只选择到文件那层的文件夹.
二就是import hello.*;这样,import 
三就是在jb中打到用到的clss和java文件
但是还是没办法老是提示
"InfoAction.java": cannot find symbol; symbol  : class InfoForm, location: class hello.InfoAction at line 34, column 37我现在把两个文件和文件夹结构发出来InfoAction.javapackage hello;import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
import InfoAction;
public final class InfoAction extends Action {    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
    throws Exception {        // These "messages" come from the ApplicationResources.properties file
        MessageResources messages = getResources(request);        /*
         * Validate the request parameters specified by the user
         * Note: Basic field validation done in InfoForm.java
         *       Business logic validation done in InfoAction.java
         */
        ActionMessages errors = new ActionMessages();
        String userName = (String)((InfoForm) form).getUserName();
String passWord = (String)((InfoForm) form).getPassWord();
        request.setAttribute("userName", userName);
        request.setAttribute("passWord", passWord);
        request.removeAttribute(mapping.getAttribute());
        return (mapping.findForward("InputInfo"));    }
}用到的InfoFormInfoForm.javapackage hello;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;public final class InfoForm extends ActionForm {    private String userName = null;
    private String passWord = null;
    public String getUserName() {
        return (this.userName);
    }    public void setUserName(String userName) {
        this.userName = userName;
    }    public String getPassWord() {
        return (this.passWord);
    }    public void setPassWord(String PassWord) {
        this.passWord = passWord;
    }    public void reset(ActionMapping mapping, HttpServletRequest request) {
        this.userName = null;
 this.passWord = null;
    }    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {        ActionErrors errors = new ActionErrors();        if ((userName == null) || (userName.length() < 1))
            errors.add("username", new ActionMessage("hello.no.username.error"));
        if ((passWord == null) || (passWord.length() < 1))
            errors.add("username", new ActionMessage("hello.no.username.error"));
        return errors;
    }
}出错就出在from文件里文件夹结构如下root文件夹下
src就是我写的这几个java文件位置
WEB-INF\classes\hello
放的是编好的class文件,现在InfoForm.class文件已编译成功,在文件夹下有了

解决方案 »

  1.   

    <struts-config>
      
        <!-- ======== Form Bean Definitions =================================== -->
        <form-beans>
            <form-bean name="HelloForm" type="hello.HelloForm"/>
    <form-bean name="InfoForm" type="hello.InfoForm"/>
        </form-beans>  <!-- ========== Action Mapping Definitions ============================== -->
      <action-mappings>
        <!-- Say Hello! -->
        <action    path      = "/HelloWorld"
                   type      = "hello.HelloAction"
                   name      = "HelloForm"
                   scope     = "request"
                   validate  = "true"
                   input     = "/hello.jsp"
         >
            <forward name="SayHello" path="/hello.jsp" />
        </action>
        <action    path      = "/InputInfo"
                   type      = "hello.InfoAction"
                   name      = "InfoForm"
                   scope     = "request"
                   validate  = "true"
                   input     = "/input.jsp"
         >
            <forward name="InputInfo" path="/input.jsp" />
        </action>
      </action-mappings>
        <!-- ========== Message Resources Definitions =========================== -->  <message-resources parameter="hello.application"/></struts-config>