最近研究SSH,发现一个问题,struts2配置文件可以使用通配符,例如:
<struts>
  <package name="sshweb" extends="struts-default" namespace="/common">
    <action name="*_*" class="{1}" method="{2}" >
      <result>/pages/{1}.jsp</result>
      <result name="input" >/jsp/{1}.jsp</result>
      <result name="C0101001" type="redirectAction">C0101001_execute</result>
      <result name="C0101002" type="redirectAction">C0101002_execute</result>
      <result name="C0101003" type="redirectAction">C0101003_execute</result>
      <result name="C0101004" type="redirectAction">C0101004_execute</result>
      <result name="C0101005" type="redirectAction">C0101005_execute</result>
    </action>
  </package>
</struts>使用通配符,极大的简化了配置文件的设置,但是spring配置文件不知道能不能想struts2那样使用通配符,
否则枯燥的配置文字太多了。有经验的朋友告知一下,谢谢!顺便探讨一下,struts2的返回结果中name属性好像不能使用通配符,要是这也能用通配符,那配置文件简直爽坏了,上百个类只需十几行配置文字就搞定了。

解决方案 »

  1.   

    spring有个autowired="byName"很方便,楼主去研究一下
      

  2.   

    楼上的你说的是自动装载吗?
    我不要自动装载,就要在spring把struts的重新对应一遍。
    唉,spring到底有没有类似通配符的方法啊,不然可能几行的配置代码要重复几百行。
      

  3.   

    这个时候就是要声明式或者用ant生成
      

  4.   

    spring是面向容器编程的,好向没有通配符