哪位高手愿意给出Struts关于多模块应用的简单的比较完整的开发实例,不要简单的说用SwitchAction等,高分相送!谢谢!

解决方案 »

  1.   

    org.apache.struts.actions.SwitchAction SwitchAction主要在多模块应用中执行模块切换作用。 在Struts多模块工程中有两种方法可以切换到新模块上.首先,您可以在 struts-config.xml 中创建一个新的全局或局部转发“success”(参见下面代码)。然后可以使用 mapping.findForward("success") 切换到这个新模块上来。 
    <forward name="success"   contextRelative="true"
       path="/newModule/index.do"  redirect="true"/> 
    contextRelative=true的意思是path是相对于应用上下文的路径,contextRelative=false则是指path是相对于模块上下文的路径。 其次,创建一个如下所示的操作,其类型是一个 SwitchAction 操作: <action path="/switchTo" type="org.apache.struts.actions.SwitchAction" validate="false" /> 然后在 struts-config-newModule.xml 中创建如下所示的操作映射。 <action-mappings>
       <action path="/index" type="com.asprise.struts.newmodule.action.IndexAction">
          <forward name="success" path="/index.jsp"/>
       </action>
    </action-mappings> 接下来,编写 easyStruts/newModule/index.jsp 的代码。index.jsp 只会显示一条消息“<h1>Youare in module: newModule</h1>”。现在,启动 Tomcat 服务器,并输入 http://127.0.0.1:8080/easyStruts/switchTo.do?prefix=/newModule&page=/index.do既可。如果您想切换回默认的模块,只需输入 http://127.0.0.1:8080/easyStruts/switchTo.do?prefix=&page=/owner.jsp 即可。 
      

  2.   

    以前学struts时写过一个购物车的简单实现,需要的话留个邮箱!
      

  3.   

    ====================
    [email protected],谢谢!
      

  4.   

    Mr.TSing 回答的也不错,回去研究下,谢先!