求教各位,我想頁面加載的時候就調用query()方法
url 應該怎麼寫?
我知道Action的是http://localhost:8080.../member.do
DispatchAction的是http://localhost:8080.../member.do?method=query
那LookupDispatchAction 的是什麽???????????急 啊public class MemberAction extends LookupDispatchAction {
    //重寫抽象方法
    //用一個MAP保存資源文件KEY和方法名的映射
    protected Map getKeyMethodMap() {
        System.out.println("進入方法");
        Map map = new HashMap();
        map.put("info.member.query", "query");
        map.put("info.member.insert", "insert");
        return map;
    }
    public ActionForward query(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        MemberForm memberForm = (MemberForm) form;
        try{request.setCharacterEncoding("utf8");}catch(Exception e){}
        String memid = memberForm.getMemid();
        String name = memberForm.getName();
        String sex = memberForm.getSex();
        String type = memberForm.getType();
        
        System.out.println("request: " + request.getParameter("name"));
        
        System.out.println(memid);
        System.out.println(name);
        System.out.println(sex);
        System.out.println(type);
        DataClass dc = new DataClass();
        ArrayList al = dc.queryMember(memid, name, sex, type);
        request.setAttribute("al", al);
        
        return mapping.findForward("member");
    }

解决方案 »

  1.   

    你直接写这样http://localhost:8080.../member.do?method=query不可以吗?这样应该是没问题的呀,你把你的struts配置文件贴出来一下,看看你是怎么配置的?
      

  2.   

    下面是官方的使用示例: 
    public abstract class LookupDispatchAction 
    extends DispatchAction An abstract Action that dispatches to the subclass mapped execute method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping. To configure the use of this action in your struts-config.xml file, create an entry like this: <action path="/test" 
    type="org.example.MyAction" 
    name="MyForm" 
    scope="request" 
    input="/test.jsp" 
    parameter="method"/> which will use the value of the request parameter named "method" to locate the corresponding key in ApplicationResources. For example, you might have the following ApplicationResources.properties: button.add=Add Record 
    button.delete=Delete Record And your JSP would have the following format for submit buttons: <html:form action="/test"> 
    <html:submit property="method"> 
    <bean:message key="button.add"/> 
    </html:submit> 
    <html:submit property="method"> 
    <bean:message key="button.delete"/> 
    </html:submit> 
    </html:form> Your subclass must implement both getKeyMethodMap and the methods defined in the map. An example of such implementations are: protected Map getKeyMethodMap() { 
    Map map = new HashMap(); 
    map.put("button.add", "add"); 
    map.put("button.delete", "delete"); 
    return map; 
    } public ActionForward add(ActionMapping mapping, 
    ActionForm form, 
    HttpServletRequest request, 
    HttpServletResponse response) 
    throws IOException, ServletException { 
    // do add 
    return mapping.findForward("success"); 
    } public ActionForward delete(ActionMapping mapping, 
    ActionForm form, 
    HttpServletRequest request, 
    HttpServletResponse response) 
    throws IOException, ServletException { 
    // do delete 
    return mapping.findForward("success"); 
      

  3.   

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
      <data-sources />
      <form-beans >
        <form-bean name="memberForm" type="lianxi_struts.form.MemberForm" />
        <form-bean name="diplayForm" type="lianxi_struts.form.DiplayForm" />  </form-beans>  <global-exceptions />
      <global-forwards />
      <action-mappings >
        <action
          attribute="memberForm"
          input="/member.jsp"
          name="memberForm"
          path="/member"
          parameter="method"
          scope="request"
          type="lianxi_struts.action.MemberAction">
            <forward name="member" path="/member.jsp"></forward>
        </action>
        
        
      </action-mappings>  <message-resources parameter="lianxi_struts.ApplicationResources" />
    </struts-config>
      

  4.   

    LZ你这个写http://localhost:8080.../member.do?method=query
    它报什么错呢?
      

  5.   

    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Action[/member] missing resource in key method map
    org.apache.struts.actions.LookupDispatchAction.getLookupMapName(LookupDispatchAction.java:230)
    org.apache.struts.actions.LookupDispatchAction.getMethodName(LookupDispatchAction.java:271)
    org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:173)
    org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:150)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:46)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
      

  6.   

    http://topic.csdn.net/u/20080615/17/4c9873bf-d00b-4dba-a579-efe35ce24610.html去看看,和你一样的错
      

  7.   

    http://blog.csdn.net/qlampskyface/archive/2005/01/22/263755.aspx
      

  8.   

    我寫了一個另外的普通的Action去調用query方法頁面可以正常顯示。按鈕正常使用~頁面應該沒錯誤。
    我把資源文件換了英文,結果一樣。還是同樣錯誤。。資源文件我的經過編碼轉換應該也沒什麽問題
    。。迷惑中
      

  9.   

    LZ,http://blog.csdn.net/qlampskyface/archive/2005/01/22/263755.aspx这篇文章看了吗?55555555555.............我也没辙了,继续关注中
      

  10.   

    謝謝你的幫忙哈這個文章我也看了。。不過他和我的情況不同。他是配置文件整合。。可是我只有一個action配置文件就那麼一點點,沒有整合這個困難啊,我的是頁面無法加載。。一切正常就是不能加載。。
      

  11.   


    LZ,建议你先换换环境,休息一下然后再从头仔仔细细的检查一遍所有的地方,看看是不是哪里写错了,struts1的配置应该是很简单的呀,思路也好清晰的,再好好看看吧
      

  12.   

    簡單來說我想在打開瀏覽器輸入地址以後。
    讓query方法運行然後查詢出數據成功加載頁面
      

  13.   

    LZ 找本书看一看吧,分发action有好多种的,每种都有不同的特点及配置方式
      

  14.   

    沒有解決。我用了一種古老的方式解決了頁面加載問題。可是我還是想知道lookup的action怎麼加載頁面