Java代码 
<html:form action="/userAction/showUserList.do">   
   <html:submit>显示所有用户</html:submit>   
   </html:form>   <html:form action="/userAction/showUserList.do">
    <html:submit>显示所有用户</html:submit>
    </html:form>上面是我的提交 
下面是struts配置 
Java代码 
<action path="/userAction/showUserList"  
        type="usermodule.UserAction"  
        name="userForm"  
        parameter="showUserList"  
        scope="request"  
        input="/root/user/userlist.jsp">   
        <forward name="success" path="/root/user/userlist.jsp"></forward>   
</action>  然后点击显示所有用户后有没输出信息 
下面是jsp页面 
Java代码 
<table>   
        <tr>   
          <td>登陆名 </td>   
          <td>真实姓名 </td>   
          <td>EMAIL</td>   
        </tr>   
           <logic:present name="userList">   
           <logic:iterate id="UserForm" name="userList" type="usermodule.DBUser">   
             <tr>   
               <td>   
                 <bean:write name="UserForm" property="username"/>   
               </td>   
               <td>   
                 <bean:write name="UserForm" property="realname"/>   
               </td>   
               <td>   
                 <bean:write name="UserForm" property="email"/>   
               </td>   
             </tr>   
           </logic:iterate>   
           </logic:present>   
           <tr><td>   
           <html:form action="/userAction/showUserList.do">   
             <html:submit>显示所有用户</html:submit>   
           </html:form>   
           </td></tr>   
    </table>  <table>
        <tr>
          <td>登陆名 </td>
          <td>真实姓名 </td>
          <td>EMAIL</td>
        </tr>
           <logic:present name="userList">
           <logic:iterate id="UserForm" name="userList" type="usermodule.DBUser">
             <tr>
               <td>
                 <bean:write name="UserForm" property="username"/>
               </td>
               <td>
                 <bean:write name="UserForm" property="realname"/>
               </td>
               <td>
                 <bean:write name="UserForm" property="email"/>
               </td>
             </tr>
           </logic:iterate>
           </logic:present>
           <tr><td>
           <html:form action="/userAction/showUserList.do">
             <html:submit>显示所有用户</html:submit>
           </html:form>
           </td></tr>
    </table>我在action中设置了断点,调试时发现根本就没有进入到action类不明白啊,又没有显示错误 

解决方案 »

  1.   

    把你的action贴出来。
    你的struts-config.xml中配置了 parameter
    你是不是用了DispatchAction。
      

  2.   

    你的UserAction是不是继承错了  应该是继承DispatchAction 
      

  3.   

    public class UserAction extends Action{
    public ActionForward execute(ActionMapping mapping,
    ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
    String myaction = mapping.getParameter();
    if(myaction.equalsIgnoreCase("addUser"))
    {
    return createUserAction(mapping,form,request,response);
    }
    else if(myaction.equalsIgnoreCase("updateUser"))
    {
    return updateUserAction(mapping,form,request,response);
    }
    else if(myaction.equalsIgnoreCase("showUserList"))
    {
    return showUserList(mapping,form,request,response);
    }
    return null;
    }这个是我的action  我还有另外一个类似的managerAction 这两个我代码都几乎一样,可是那个可以显示managerList  这个就不行 不知道为什么 ,断点就设在
    String myaction = mapping.getParameter();
    运行时根本不停
      

  4.   


    public class UserAction extends Action{public class UserAction extends DispatchAction {
    继承错了 试试继承DispatchAction
      

  5.   

    <action path="/userAction/showUserList"  
            type="usermodule.UserAction"  
            name="userForm"  
            parameter="showUserList"  
            scope="request"  
            input="/root/user/userlist.jsp">   
            <forward name="success" path="/root/user/userlist.jsp"></forward>   
    </action>  你的action配置了parameter, 那应该是要继承DispatchAction的
      

  6.   


    我另外一个public class ManagerAction extends Action为什么又能用呢?
    我这个不是使用DispatchAction的啊,我是通过传进来的参数在execute方法中判断调用下面哪个方法来实现的,其中上面代码的其他方法都可以使用就是“showUserList”这个不行 不知道为什么
      

  7.   

    我再发出其他UserAction的其他配置<action path="/userAction/register"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="addUser"
                  validate="true"
                  scope="request"
                  input="/root/user/register.jsp">
                  <forward name="return_index" path="/index.jsp"></forward>
          </action>
          <action path="/userAction/modify"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="updateUser"
                  validate="true"
                  scope="request"
                  input="/root/user/userinfo.jsp">
                  <forward name="return_userinfo" path="/root/user/userinfo.jsp"></forward>
          </action>
          <action path="/userAction/deleteUser"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="deleteUser"
                  scope="request">
                  <forward name="success" path="/root/user/userlist.jsp"></forward>
          </action>
          <action path="/userAction/showUserList"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="showUserList"
                  scope="request"
                  input="/root/user/userlist.jsp">
                  <forward name="success" path="/root/user/userlist.jsp"></forward>
          </action>
    这样子是应该不用继承dispatchAction的
      

  8.   

    <action path="/userAction/showUserList"   
      type="usermodule.UserAction"   
      name="userForm"   
      parameter="showUserList"   
      scope="request"   
      input="/root/user/userlist.jsp">   
      <forward name="success" path="/root/user/userlist.jsp"></forward>   
    </action>   你的action配置了parameter, 那应该是要继承DispatchAction的要不就不用 在页面上放个隐藏字段 <input type="" name="method" value="showUserList"/>
    UserAction 用String myaction =request.getParameter("method")接收
      

  9.   

    刚试过就算改了 仍然是这样,根本不进入到Action,直接跳转到改userlist.jsp页面中,所以session中的“userList”是空值不显示信息
      

  10.   

    在页面上放个隐藏字段 <input type="" name="method" value="showUserList"/>
    UserAction 用String myaction =request.getParameter("method")接收
    要把 配置文件中的parameter 去掉
      

  11.   

    用隐藏表单域 再在提交的时候加action里的方法 
      

  12.   

    16楼 izard999
    你觉得这应该是什么问题?我在描述我的问题:
    关于参数传递我是通过同一个Action(userAction)配置多个Action-mapping来解决的 <action path="/userAction/register"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="addUser"
                  validate="true"
                  scope="request"
                  input="/root/user/register.jsp">
                  <forward name="return_index" path="/index.jsp"></forward>
          </action>
          <action path="/userAction/modify"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="updateUser"
                  validate="true"
                  scope="request"
                  input="/root/user/userinfo.jsp">
                  <forward name="return_userinfo" path="/root/user/userinfo.jsp"></forward>
          </action>
          <action path="/userAction/deleteUser"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="deleteUser"
                  scope="request">
                  <forward name="success" path="/root/user/userlist.jsp"></forward>
          </action>
          <action path="/userAction/showUserList"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="showUserList"
                  scope="request"
                  input="/root/user/userlist.jsp">
                  <forward name="success" path="/root/user/userlist.jsp"></forward>
          </action>
          <action path="/userAction/userinfo"
                  type="usermodule.UserAction"
                  name="userForm"
                  parameter="userInfo"
                  scope="request"
                  input="/root/user/userinfo.jsp">
                  <forward name="success" path="/root/user/userinfo.jsp"></forward>
          </action>
    mapping如上,其中里面的register试过是没有问题的,其他还没有测试,但在另外一个模块中我试过了里面的全部都没有问题。在action中设置的断点发现没有在该断点停下,运行时,点击显示所有用户,直接跳到userlist页面没有显示错误,但是没有userlist信息。如果是参数问题不至于连action execute方法都没有执行啊? 起码也得显示错误啊
      

  13.   

    在action中用request.getParameter("")接受。。
      

  14.   

    确实,半年多美玩struts了, 细节大部分差不多丢了, 思路还在.!
    LZ像你这样多个映射对应一个Action的话, 你不同的action应该有不同的处理请求的方法,你就那样搞,所有的action都跑去调用execute, 这样是你想要的吗.?
      

  15.   


    初学struts,这个是在一本书里的例子看来的,会有什么问题吗?
      

  16.   

    书是好东西,但是最好的不是书, 是官方文档.!
    LZ你这样当然会有问题.! 你什么请求都给一个方法处理.. 不是不可以处理, 要你写很多if,你不会觉得很臃肿吗.? 随着你的action越来越多, if也越来越多?
    你要是想多个路径映射到一个action的类又有不同的处理方法,
    继承DispatchAction, 方法名不要叫execute了, 随便起个名, 但是在你struts的配置文件中的action中的parameter定义一个名字.  然后在页面上发送请求的时候, 加一个请求参数,get/post请求都可以,
    name就为parameter的name,value为方法名! 
      

  17.   

    恩,问题解决了,不是参数问题,发现我的form有validate,但是配置那里没有改为false,加上后就没有问题了,虽然izard999没有帮我解决这个问题,不过还是学到好多,分就给你啦
      

  18.   

    validate一般都丢在客户端了.!   特殊情况下需要服务端校验再说