struts 一

struts-config.xml 下的action-mapping元素

在本例中action先接受SavaAction的请求,并映射到struts.sample.cap5.sample1.action.SaveAction,同时将CheckForm内容一并传送。

 <action-mappings >
    <action
      attribute="CheckForm"
      input="/user.jsp"
      name="CheckForm"
      path="/SavaAction"
      scope="request"
      type="struts.sample.cap5.sample1.action.SaveAction"
      validate="true">
      <forward name="success" path="/user.jsp" />
    </action>
    

  </action-mappings>
在action-mapping元素下可以定义0个或1个以上的action元素。每个action元素接受path属性定义的请求,并映射到type属性所定义的具体的Action对象。在映射过程中,将name属性定义的ActionForm内容一并传送过来。
input属性表示请求验证失败之后返回的页面
validate属性指定了是否需要ActionForm验证
forward属性制定了页面成功或失败之后跳转的页面
parameter属性指定了传送方式

scope实行指定了作用范围,常用值session 和 request

完整的struts-config.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="CheckForm" type="struts.sample.cap5.sample1.form.CheckForm" />
    <form-bean name="CheckForm2" type="org.apache.struts.validator.DynaValidatorActionForm">
      <form-property name="userName" type="java.lang.String" />
      <form-property name="age" type="int" />
      <form-property name="email" type="java.lang.String" />
      <form-property name="passWord" type="java.lang.String" />
    </form-bean>

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="CheckForm"
      input="/user.jsp"
      name="CheckForm"
      path="/SavaAction"
      scope="request"
      type="struts.sample.cap5.sample1.action.SaveAction"
      validate="true">
      <forward name="success" path="/user.jsp" />
    </action>
    

  </action-mappings>

  <message-resources parameter="resources.application" />
  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
  </plug-in>
</struts-config>











                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值