action代码public class MeetingAction extends DispatchAction { public ActionForward intoIndex(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
                TimeConversion tc = new TimeConversion();
String dateNow = tc.getDateNow();
String num = "";
switch (tc.getDayOfWeekNow()) {
case 1:
num = "一";
break;
case 2:
num = "二";
break;
case 3:
num = "三";
break;
case 4:
num = "四";
break;
case 5:
num = "五";
break;
}
String weekNow = "每周" + num;
MeetingDAO mdao = DAOFactory.getMeetingDAOInstants();
List<MeetingVO> all = null;
try {
all = mdao.listMeetingForDate(dateNow, weekNow);
} catch (Exception e) {
LogBean.logger.error(e.getMessage());
}
request.setAttribute("list", all);
return mapping.findForward("index");
}
}配置文件<action
      attribute="meetingForm"
      input="/meeting/index.jsp"
      name="meetingForm"
      parameter="action"
      path="/meeting/index"
      scope="request"
      type="com.anyka.meeting.action.MeetingAction">
      <forward name="index" path="/meeting/index.jsp" />
    </action>跳转url:http://XX/meeting/index.do?action=intoIndex
报错严重: Servlet.service() for servlet action threw exception
javax.servlet.ServletException: Request[/meeting/index] does not contain handler parameter named 'action'.  This may be caused by whitespace in the label text.
at org.apache.struts.actions.DispatchAction.unspecified(DispatchAction.java:215)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:249)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.anyka.filter.EncodingFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
哪位可以告诉我到底是为什么。。我是直接在地址栏里打上url,没有经过表单提交。。

解决方案 »

  1.   

    你确定你url没打错,报的错误是你没有带action参数
      

  2.   

     not contain handler parameter named 'action'
    不能正确执行需要执行的方法
    也就是缺少action=方法名这个东西
      

  3.   

    http://XX/meeting/index.do?action=intoIndex
    这个是我的url。是什么问题呢?
      

  4.   

    如何修改呢?我action在配置文件里面是有配置的
      

  5.   

    楼主,你把action换成别的吧,用method挺好的啊。action可能会和form里面的action冲突。应该是关键字导致struts解析URL出错。
      

  6.   

    @parameter:为当前的Action配置参数,可以在Action的execute()方法中,通过调用ActionMapping的getParameter()方法来获取参数action的parameter参数 是这么解释的
    这个parameter应该不是指的封装request里面的参数
    你自己从request中获取 action参数 试试
      

  7.   

    我继承的是dispatchAction.....用此url链接方法的时候就报错了。方法根本就没有执行
      

  8.   

    直接用url访问方法。明显不是表单提交你看清楚
      

  9.   

    不含有叫做'action' 的处理程式叁数。 这可能由标示本文的空白所引起。
      

  10.   

     parameter="action" 去掉这个参数设置
      

  11.   

    你的action 是= index.do ? 
      

  12.   

    在我的action 中加入public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    }
      

  13.   

    parameter="action" ?
    我怎么记得是 method=“action”
    才是这样调用的 index.do?action=intoIndex
    parameter 改 method试试
      

  14.   


    楼主,你两个地方都改了么?
    struts.xml里面 parameter="action"改为 parameter="method"
    url你改为:http://XX/meeting/index.do?method=intoIndex
      

  15.   


    有区别么。。方法名只是个名字我用abcd一样可以。配置文件的东西。。不要那么死板。。别人method你就全部method没用的
      

  16.   

    LZ对你无语了。
    ①attribute="TargetSearchForm"
    name="TargetSearchForm"
    parameter="action"path="/TargetSearch"
    scope="request"
    type="com.monitor.action.targetstore.TargetSearchAction"
    URL:http://127.0.0.1:8080/TargetSearch.do?action=toTargetSearchTop
    报和你一样的错。
    ②attribute="TargetSearchForm"
    name="TargetSearchForm"
    parameter="bbb"path="/TargetSearch"
    scope="request"
    type="com.monitor.action.targetstore.TargetSearchAction"
    URL:http://127.0.0.1:8080/TargetSearch.do?bbb=toTargetSearchTop
    页面跳转正常。
    这两个例子说明什么?说明action是个关键字,struts的API在解析URL时出错了。有兴趣可以去看下struts的源码,看看它是怎么解析URL的。哎,无语啊,对LZ的固执很感慨。
    说明,action是个
      

  17.   

    LZ对你无语了。
    ①attribute="TargetSearchForm"
    name="TargetSearchForm"
    parameter="action"
    path="/TargetSearch"
    scope="request"
    type="com.monitor.action.targetstore.TargetSearchAction"
    URL:http://127.0.0.1:8080/TargetSearch.do?action=toTargetSearchTop
    报和你一样的错。
    ②attribute="TargetSearchForm"
    name="TargetSearchForm"
    parameter="bbb"
    path="/TargetSearch"
    scope="request"
    type="com.monitor.action.targetstore.TargetSearchAction"
    URL:http://127.0.0.1:8080/TargetSearch.do?bbb=toTargetSearchTop
    页面跳转正常。
    这两个例子说明什么?说明action是个关键字,struts的API在解析URL时出错了。有兴趣可以去看下struts的源码,看看它是怎么解析URL的。哎,无语啊,对LZ的固执很感慨。楼主,你创新可以,但是不能盲目自信呀。
      

  18.   


    我写这个新系统才出现这样的错误的。。以前的系统全是这样写的没有问题。。
    哦还有我问题解决了......呵呵。唉....不是我固执是你没了解到关键的地方。。而且这个也不是我创新。。谁说parameter的配置属性一定要method.....?
      

  19.   

    LZ果然还在固执
    Action是关键词 并不是说 全要用成Method 这仅仅是一个参数名而已,但不要用关键字
    LZ还是虚心点好
      

  20.   

    你表单里面不包含action这个参数
    也就是说,你的请求参数需要包含action=intoIndex,才会正确执行
      

  21.   

    我不是表单提交的。。我是直接请求url。url里面有参数了问题我现在已经解决了
      

  22.   

    这不是我固执不固执的问题其实我是希望你不要走进误区。虽然我不是什么高手但是一人解决一个问题大家都能学到点东西。就能共同,进步.....出现这个错误绝对不是你说的我占用关键字。。
    何况我现在已经把问题解决..我的parameter参数依然是action
      

  23.   

    别不懂装懂
    action什么时候成关键字了
    我以前的项目也都是用action没报过错
    你不要在地址栏打URL了 
    用form提交试试注意加上 method="post"
    配置应该是没有错的
      

  24.   

    这位兄弟说得没错。一般情况如果是表单请求加上 method="post"是可以解决这个问题的,但我的不是表单请求,我的是直接用url访问这个方法。。有不明白的。可以看看上面几楼我的回复。
    哦还有一会我会和大家分享讨论下这个问题是怎么解决的
      

  25.   

    用js访问的是把 
    一样可以设置method="post"document.forms[0].action="http://XX/meeting/index.do?action=intoIndex";
    document.forms[0].method="post";
    document.forms[0].submit();
      

  26.   

    不是我就是地址栏里面直接访问index.jsp页面然后经过过滤url会变为http://XX/meeting/index.do?method=intoIndex。。页面无表单
      

  27.   

    你struts-config是什么,?后面就是什么
    http://XX/meeting/index.do?method=intoIndex
    对应struts-config
    parameter="method"
      

  28.   

    不好意思我刚刚的url写错了我的是
    http://XX/meeting/index.do?action=intoIndex后来错误解决是因为我发现dispatchAction有一个默认的action方法unspecified()这个方法是在你没有指定其他方法时他会默认跳转到这个方法。
    可能是因为我不是表单提交没有指定method="post"所以导致解析错误
    但是加入了unspecified()这个方法以后就不会存在这个问题了。
    --------------------------------------------------------------------------------------------
    可能我的理解还是有错误,如果有大虾能指出这个问题的关键原因小弟感激不尽....加满100分送您
      

  29.   

    还是这个问题啊,你的request参数里面,不包含action=intoIndex,
    所以导致了dispatchMethod找不到相应的执行方法,因此调用unspecified方法。而这个方法的默认实现就是Exception。你实现了一个,就是什么也不报错,但是并不是你要的,执行intoIndex方法。所以,你还是要检查你的request参数
      

  30.   

    奇怪的就是我写了unspecified方法...我的url就找到intoIndex方法了
    不仅仅是不报错。因为我写得unspecified方法是空方法。执行的的确是intoIndex方法
      

  31.   

    那你直接debug一下啊,别告诉我你没下载过struts的源代码
      

  32.   

    你确定你重写后你的intoIndex方法执行了么?
    打断点试试看看进去没
    调用unspecified方法会抛出异常自动跳转至input的属性
     input="/meeting/index.jsp"
    跳转的这个页面和你执行intoIndex方法跳转的页面一样
      

  33.   

    好吧,我说action是struts的关键字是错误的。
    刚才研究了下struts的代码,发现出现直接打URL请求出异常的原因为:
    以楼主的URL为例子,http://XX/meeting/index.do?action=intoIndex
    是执行完intoIndex方法之后,会返回一个Forward,此返回的Forward是会以doPost方式执行。所以request中没有发现action这个参数。
    Struts源码中出现如下判断:public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
            if (isCancelled(request)) {
                ActionForward af = cancelled(mapping, form, request, response);            if (af != null) {
                    return af;
                }
            }        // Get the parameter. This could be overridden in subclasses.
            String parameter = getParameter(mapping, form, request, response);        // Get the method's name. This could be overridden in subclasses.
            String name =
                getMethodName(mapping, form, request, response, parameter);        // Prevent recursive calls
            if ("execute".equals(name) || "perform".equals(name)) {
                String message =
                    messages.getMessage("dispatch.recursive", mapping.getPath());            log.error(message);
                throw new ServletException(message);
            }        // Invoke the named method, and return the result
            return dispatchMethod(mapping, form, request, response, name);
        }
    protected ActionForward dispatchMethod(ActionMapping mapping,
            ActionForm form, HttpServletRequest request,
            HttpServletResponse response, String name)
            throws Exception {
            // Make sure we have a valid method name to call.
            // This may be null if the user hacks the query string.
            if (name == null) {
                return this.unspecified(mapping, form, request, response);
            }


    。谢谢楼主让我保持清醒,呵呵
      

  34.   

    肯定执行了。。直接访问/meeting/index.jsp是不会有数据显示的
    intoIndex执行以后页面才会显示数据
      

  35.   

    所以表单提交要加上method="post"
    ------------------------------------------------------------------------------------------------
    而url直接提交现在还是个谜,现在更奇怪的事情出现了。运行成功以后即使我删除unspecified方法,程序依然正常执行,无错误
    -----------------------------------------------------------------------------------------------
      

  36.   

    是struts1.2么。看了一下异常堆栈上并无MeetingAction的调用呀。配置问题吧。
    at org.apache.struts.actions.DispatchAction.unspecified(DispatchAction.java:215)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:249)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      

  37.   

    试了一下,struts1.3.10表示毫无压力,能正确执行。
    你没写unspecified时不行,写了就好了,然后删掉也好了。看来是缓存问题呀。另:parameter=action没什么问题,从request.getParameter("action")中取的值。
    如果没配parameter或配了但传的参数是null,都报servlet exception;但如果配了传的参数指定的方法不存在,报的是nosuchmethod exception.