如题,我的struts配置文件如下:
    <action path="/jsp/xxAction" parameter="method"
      type="com.action.XxAction">
      <forward name="search" path="/jsp/code/search.jsp" />
      <forward name="success" path="/jsp/code/success.jsp" />
      <forward name="error" path="/jsp/code/error.jsp" />
    </action>
请问如果我的action继承spring的DispatchActionSupport,如果url为
http://.../jsp/xxAction.do
那么我如何设定一个默认的处理方法呢一般没有method请求参数的话会报错:
javax.servlet.ServletException: Request[/jsp/xxAction] does not contain handler parameter named 'method'.  This may be caused by whitespace in the label text.
注:不要说为什么不加method参数之类的,我这个问题问的就是不加method参数,如何实现一个默认的处理方法,谢谢!

解决方案 »

  1.   

    这个ACTION的PATH为什么要/JSP/XXACTION 难道你把ACTION放在JSP下?
    直接就xxaction.do调用而且 ACTION要交给STUTAS托管type="org.springframework.web.struts.DelegatingActionProxy">
      

  2.   

        <action
          attribute="hdmainForm"
          name="hdmainForm"
          parameter="method"
          path="/main"
          scope="request"
          type="org.springframework.web.struts.DelegatingActionProxy">
          <forward name="index" path="/index.jsp" />
          <forward name="Add_success" path="/web/Add_success.jsp" />
          <forward name="add" path="/Add.jsp" />
          <forward name="update" path="/web/update.jsp" />
          <forward name="deldet" path="/web/deldet.jsp" />
          <forward name="deldet_success" path="/web/deldet_success.jsp" />
          <forward name="upload" path="/web/upload.jsp" />
          <forward name="deldet_failure" path="/web/deldet_failure.jsp" />
          <forward name="showlist" path="/showlist.jsp" />
          <forward name="update_success" path="/web/update_success.jsp" />
          <forward name="Add_Failure" path="/web/Add_Failure.jsp" />
          <forward name="update_failure" path="/web/update_failure.jsp" />
        </action>
    这是我的,你可以参考下,不需要/JSP/ACTION的 难道你自动生成放在struts action下么?
      

  3.   

    路径怎么写不是问题,主要问题是如何为DispatchActionSupport指定一个默认的处理方法
    比如我的action实现里面有N个方法
    serch(...){
    ...
    }
    update(...){
    ...
    }
    insert(...){
    ...
    }
    如果访问的url为http://.../jsp/xxAction.do
    不指定method=search(http://.../jsp/xxAction.do?method=search)会报错
    javax.servlet.ServletException: Request[/jsp/xxAction] does not contain handler parameter named 'method'.  This may be caused by whitespace in the label text.
    请问有没有办法设置一个默认处理方法
    不指定method请求参数的话,默认执行search方法
      

  4.   

    不知道struts的DispatchAction可不可以,DispatchActionSupport是spring里面的类继承了struts的DispatchAction
      

  5.   

    @Override
    protected ActionForward unspecified(ActionMapping mapping, ActionForm form,        HttpServletRequest request, HttpServletResponse response) throws Exception {
    }
      

  6.   

    public class XXXXX extends DispatchAction {
     @Override
     protected ActionForward unspecified(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) throws Exception {
    这就是不传递方法参数的默认调用。

    }