struts-config.XML中的解释

来源:互联网 发布:sql从大到小排序 编辑:程序博客网 时间:2024/05/22 10:37

在struts-config.XML中<controller>元素还提供另一个特性以控制<forward>元素的的name属性如何被解释。该<controller>元素用于联合<action>元素中input属性,如下所示:

<action path="/editCustomerProfile"
type="packageName.EditCustomerProfileAction"
name="customerProfileForm"
scope="request"
input="profile">
<forward name="profile" path="/CustomerProfile.jsp"/>
<forward name="sUCcess" path="/MainMenu.jsp"/>
</action>
<controller>
<set-property property="inputForward" value="true"/>
</controller>

       上述的<action>元素包含一个input属性及一个向前名称;该前进名称与<forward>中的相同。在上述的<controller>配置中,当ActionForm.validate(…)返回一个非空或非null的ActionErrors对象,RequestProcessor将选择<forward>元素,其name属性与<action>元素的input属性拥有相同的值;除非用子类取代RequestProcessor,该行为是确认遇到错误的标准行为。对下面的<controller>元素声明,当ActionForm.validate(…)返回一个非空或非null的ActionErrors对象,input属性提供一个向前的URL以代替向前发生ActionForward的名称。在inputForward属性不存在时,这是默认的配置。

<!--
  名称:controller
  描述:用于配置ActionServlet
  数量:最多一个
  属性:
   @bufferSize:指定上传文件的输入缓冲的大小.默认为4096
   @className:指定当前控制器的配置类.默认为org.apache.struts.config.ControllerConfig
   @contentType:指定相应结果的内容类型和字符编码
   @locale:指定是否把Locale对象保存到当前用户的session中,默认为false
   @processorClass:指定负责处理请求的Java类的完整类名.默认org.apache.struts.action.RequestProcessor
   @tempDir:指定文件上传时的临时工作目录.如果没有设置,将才用Servlet容器为web应用分配的临时工作目录.
   @nochache:true时,在相应结果中加入特定的头参数:Pragma ,Cache-Control,Expires防止页面被存储在可数浏览器的缓存中,默认为false
 -->
 <controller
  contentType="text/html;charset=UTF-8"
  locale="true"
  processorClass="CustomRequestProcessor">
 </controller>

原创粉丝点击