2.用structs的话,怎么样实现点击button转到另一个页面  
  可以用form提交,也可以写个js
3.怎么在structs里面用js校验后再提交到action  
  onclick="return ...."

解决方案 »

  1.   

    1。从action返回页面尽量避免用global forward,在struts-config.xml中给action配置forward,比如
    <action-mappings>
        <action name="****" path="/****" scope="****" type="****">
          <forward name="###" path="/***.jsp" />
        </action>
      </action-mappings>
    然后在action文件里return mapping.findForward("###")即可以将请求转发到相应的jsp
    2。按钮的type属性设为submit并放入一个form,然后将请求提交到某个action,action中的处理同上
    3。同楼上
      

  2.   

    global forward容易出这样的问题。你直接定义一个局部转发就可以了。
      

  3.   

    谢谢楼上各位,我配了局部的forward,在action中写return(mapping.findForward("r"));
    但是还是返回不了页面报下面的错误,请问是什么原因??java.lang.ExceptionInInitializerError
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1187)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:214)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:120)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3022)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1925)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1848)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1288)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.struts.util.ModuleUtils.(ModuleUtils.java:47)
    ... 16 more
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    ... 20 more
    Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:385)
    ... 21 more
      

  4.   

    我写的一个简单的structs小程序,想从action返回页面
    在structs-config.xml里配了局部的forward
    attribute="wForm"
    input="/form/w.jsp"
    name="wForm"
    path="/w"
    scope="request"
    type="test.struts.action.WAction" >在action中写的是return(mapping.findForward("r"));
    运行时报错如下
    java.lang.ExceptionInInitializerError
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1187)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:214)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:120)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:165)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3022)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1925)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1848)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1288)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at org.apache.struts.util.ModuleUtils.(ModuleUtils.java:47)
    ... 16 more
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    ... 20 more
    Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:385)
    ... 21 more如果改成return mapping.findForward("r");
    就提示
    Error 404--Not Found 
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.4.5 404 Not Found
    The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
    找不到页面
    请问这是什么原因 谢谢 
      

  5.   

    user包下的addAction  成功跳转到main.jsp 错误到errer.jsp
    <action-mappings>
        <action name="addAction" path="/addAction.do" type="user.addAction">
          <forward name="s" path="/main.jsp" />
          <forward name="errer" path="/errer.jsp" />
        </action>
      </action-mappings>
      

  6.   

    ,在struts-config.xml中给action配置forward,比如
    <action-mappings>
        <action name="" path=""scope="" type="">
          <forward name="r" path="/***.jsp" />
        </action>
      </action-mappings>可能是在你在path中的/**.jsp配置有错误了
      

  7.   

    在js 中的 function{} 中写 这样一段话 :document."struts-config.xml文件中的该页面对应的<form-bean> 对应的name属性名".submit();例如 :
     
    <form-bean   name="approveStreamSetForm" 
    type="com.sunrising.AttendanceSystem.actionform.approveManageForm.ApproveStreamSetForm"/> 
    那么就写成 function emample(){
            document.approveStreamSetForm.submit();
     }
      

  8.   

    用Button实现跳转你可以在JAVASCRIPT里定义一个函数在这里获取Form.action 然后form.submit,,之后在Button的Onclick事件里调用该方法,就可以了!我是这么实现的 也许有好的方法。