随笔-60  评论-117  文章-0  trackbacks-0

不知道自己是怎样做到的,不过现在真的是对每一个在我生命中出现过的人心存感激。是他们让我快速的成长。是他们让我的人生不像白开水那样没有滋味。不管是酸,是咸,是苦,是辣,原来都比没有滋味要好得多。

配置ActionForm

  • <form-beans>
  • <form-bean name="HelloForm"  type="hello.HelloForm"/>
  • </form-beans>

配置全局异常处理:

  • <global-exceptions>
  • <exception key="exception" path="path.jsp" scope="request" type="java.lang.Exception"/>
  • </global-exceptions>

配置全局转发:

  • <global-forwards>
  • <forward name="dberror" path="/jsppage/databaseerror.jsp"/>
  • </global-forwards>

配置Action

  • <action-mappings>
  • <!--Say Hello!-->
  • <action path="/HelloWorld" type="hello.HelloAction" name="HelloForm" scope="request" validate="true" input="/hello.jsp">
  • <forward name="SayHello" path="/hello.jsp"/>
  • </action>
  • </action-mappings>

配置资源文件:

  • <message-resources parameter="hello.application"/>

配置Struts插件:

  • <plug-in className="neu.PlugIn">
  • <set-property property="property1" value="value1"/>
  • <set-property property="property2"value="value2"/>
  • </plug-in>

配置多个Struts-config.xml
web.xml能够为ActionServlet同时制定多个xml配置文件,文件之间以逗号分隔。
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-configB.xml</param-value>
但是,这样配置程序还是把两个文件当成一个配置解析,本质没有区分开来。
配置多个Struts-config.xml

  • <init-param>
  • <param-name>config</param-name>
  • <param-value>/WEB-INF/struts-config.xml</param-value>
  • </init-param>
  • <init-param>
  • <param-name>config/customer</param-name>
  • <param-value>/WEB-INF/struts-config-customer.xml</param-value>
  • </init-param>
  • <init-param>
  • <param-name>config/order</param-name>
  • <param-value>/WEB-INF/struts-config-order.xml</param-value>
  • </init-param>

要配置多个模块,你需要在原有的一个<init-param>的基础之上,增加模块对应的<init-param>.其中<param-name>表示为config/XXX的形式,其中XXX为对应的模块名,<param-value>中还是指定模块对应的配置文件。上面这个例子说明该应用有三个模块,分别是缺省模块,customer和order,它们分别对应不同的配置文件。
在不同模块缉拿进行转发:

  • 在<forward>中定义
  • 到其他模块
  • <forward name="toModuleB"contextRelative="true" path="/moduleB/index.do"redirect="true"/>
  • 回默认模块
  • <forward name="success" contextRelative="true"path="/login.do"/>
  • 利用org.apache.struts.actions.SwitchAction.
  • <action path="/toModule"type="org.apache.struts.actions.SwitchAction"/>

Struts控制器:

  • ActionServlet
  • RequestProcessor
  • ForwardAction
  • IncludeAction
  • DospatchAction
  • LookupDispatchAction
  • SwitchAction

 

posted on 2007-05-04 11:05 静儿 阅读(936) 评论(7)  编辑  收藏

评论:
# re: struts2 2007-05-08 21:20 | 卡夫卡

可否弱弱的问一下
有没有哪个配置可以然我点提交按钮后,可以新生成一个ie页面呢
十分感谢  回复  更多评论
  
# re: struts2 2007-05-08 21:28 | 静儿
我只知道用javascript可以做到:
document.write一下就可以了,要是用struts配置嘛,等我问一下高手再告诉你来得及吗?



@卡夫卡
  回复  更多评论
  
# re: struts2 2007-05-09 08:46 | 卡夫卡

是啊 js可以做到
就是突然想在struts里弄弄
呵呵
谢谢啦  回复  更多评论
  
# re: struts2 2007-05-10 17:39 | 卡夫卡
决定了
用 html 加到页面里就可以了
<a href = "???.jsp" target = "ereryURL">link</a>
  回复  更多评论
  
# re: struts2 2007-08-08 09:59 | ahpo
好像不是struts2而是struts1啊。。  回复  更多评论
  
# re: struts2 2007-08-10 08:14 | 静儿
哦,不是按那个分的  回复  更多评论
  
# re: struts2 2009-09-24 14:55 | 达飞Plus
strutsは始めます。  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: