是的,我新建的struts-config-hello.xml这个文件

解决方案 »

  1.   

    我在web.xml这样写的,但感觉好象子模块没有起作用:
        
        <init-param>
         <param-name>config</param-name>
         <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>    <init-param>
            <param-name>config/moduleB</param-name>
            <param-value>/WEB-INF/struts-config-hello.xml</param-value>
        </init-param>
      

  2.   

    web.xml没有问题,看看你struts-config-hello.xml里写的对不对吧,而且调用的时候要用/moduleB/xxxxx.do
      

  3.   

    可struts-config-hello.xml中的配置完全移植到struts-config.xml中是没有任何问题的。你是指在struts-config.xml中一定要这样写吗?
    <action
          ...
          <forward
            name="tohello"
            contextRelative="true"
            path="/moduleB/xxxxx.do"
            redirect="true"
            />
    </action>那是不是一定要建立一个“moduleB”的文件夹,还有,我对这里的xxxx.do里写什么不是很明确,因为我做的例子中forward一般都是指向一个页面。
    PS:我觉得有些问得有些太弱了,但初学的我真的很着急,谢谢各位了。
      

  4.   

    谁说web.xml没问题 问题就在这 要在子模块中用struts-config-hello.xml这个配置文件应该在web.xml中
    <init-param>
            <param-name>config/hello</param-name>
            <param-value>/WEB-INF/struts-config-hello.xml</param-value>
        </init-param>
    这样写 你的moduleB 是what 阿
      

  5.   

    谁说web.xml没问题 问题就在这 要在子模块中用struts-config-hello.xml这个配置文件应该在web.xml中
    <init-param>
    <param-name>config/hello</param-name>
    <param-value>/WEB-INF/struts-config-hello.xml</param-value>
    </init-param>
    这样写 你的moduleB 是what 阿?
    moduleB当然是目录的名字,我也遇到了同样的问题,不知道谁能解决
      

  6.   

    分析了一下,这是struts的一个bug,form标签中的lookup方法取得module config是默认的struts config,而不是相应模块的config
    解决方法:
    修改form标签:
    1。增加module属性,其值就是action所在的模块
    2。修改lookup方法,将
     moduleConfig = TagUtils.getInstance().getModuleConfig(pageContext);
    修改为:
     moduleConfig = TagUtils.getInstance().getModuleConfig(module,pageContext);
      

  7.   

    web.xml:
        <init-param>
            <param-name>config/moduleB</param-name>
            <param-value>/WEB-INF/struts-config-hello.xml</param-value>
        </init-param>这样是没问题的假设struts-config-hello.xml中:    <action path="/test" ..........>
          <forward name="........." path="/test.jsp" />    
        </action>那么test.do所对应的请求url为  moduleB/test.do ,
    也就是说  path="/test" 中的 "/"代表 module级目录
    forward 中的path同理假设 在web应用根有 moduleB 目录,
    其中有 aa.jsp 中 <a href="test.do"> 此url刚会请求此.do
    或直接请求 moduleB/test.do 也可
      

  8.   

    web.xml:
        <init-param>
            <param-name>config/moduleB</param-name>
            <param-value>/WEB-INF/struts-config-hello.xml</param-value>
        </init-param>的确没问题,stonecsdn(东东)你可能理解错了楼主可能卡在小问题上了,我也是这么用的,没问题
      

  9.   

    不是我理解错了,而是楼主的意思没有表达明白,我想楼主的问题是在下面的情况中出现的:
    在moduleB(或者hello)模块(目录),有一个jsp --〉formtest.jsp,这个jsp中有一个标单:
    <html:form action="/logon" method="post">
      <bean:message key="prompt.username"/>
      <html:text property="username"/>
      <br/>
      <bean:message key="prompt.password"/>
      <html:password property="password"/>
      <br/>
      <html:submit>
        <bean:message key="index.logon"/>
      </html:submit>
    </html:form>
    而关于action---〉logon.do的定义是在struts-config-moduleB.xml中定义的,在默认的struts-config.xml中没有定义,那么如果你直接运行该页面
    http://localhost:8080/strutstest/moduleB/formtest.jsp
    那么你会看到异常:Cannot retrieve mapping for action /logon。why?
    因为直接访问formtest.jsp时,struts form tag 取的module config是默认的关于struts-config.xml的module config,而不是struts-config-moduleB.xml的config,而struts-config.xml没有定义/logon.do这个action,当然找不到,会报异常了
      

  10.   

    struts的多模块开发只由在执行action的时候才有效,因为执行action时将执行ActionServlet,ActionServlet将会根据请求的连接取得相应的module config处理action
      

  11.   

    大家可以运行一下struts1.2的<html:link>标签,该标签有一个module属性专门制定了action所属的module
      

  12.   

    我顶!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!
    免费招聘、求职。IT人工作的天堂。希望能够为大家所用。