struts的struts-config

    技术2022-05-11  79

    <?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="helloForm" type="com.yourcompany.struts.form.HelloForm" />  </form-beans>//这个用来设置表单bean.如果表单具备会话或者应用范围,你可以使用name属性调用                  getAttribute()方法来得到表单的句柄,例:request.getSession().setAttribute                  ("helloForm", null);会把表彰的所有值置为null(这里的bean的范围是session  <global-exceptions />//全局异常(用的时候查资料去吧!!!!如:struts kick start(173p));  <global-forwards />//全局转发,对所有config文件都可用,例:<global-forwards><forward                                           name="whl"  path="/home.jsp></global-forwards>,另外还有一个属性,redirect如果为true为重定向,否则为转发  <action-mappings >            <action      attribute="helloForm"//允许指定不同于name的唯一标识,如果指定它,用它来在指定范围内保存                              ActionForm否则用name      input="/form/hello.jsp"//重定向回用以输入表单值的表单如:mapping.getInputForward()      name="helloForm"//用它来在指定范围内保存ActionForm,它们和<form-bean>中的name属性保持一致      path="/hello"被用来同action的请求匹配 如:<html:form action="/uewuseraddr">      scope="request"      type="com.yourcompany.struts.action.HelloAction">//指定处理该action的Action类      <forward name="sayhello" path="/hello.jsp" />//表示转发的路径,如 mapping.findForward                                                  ("sayhello")    </action>    //<action>还可以可以使用set-property书上说很有用,可是怎么讲,不太明白......  </action-mappings>  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />//定义消息资源,属性key来表示如果是用上下文来查找资源包,就使用key指定的值去查找,一般用parameter属性就可以了,这个也不太明白。。。。。。。</struts-config>还有一<data-sources>现在还没有学到,以后在补允吧。。。。。 

    最新回复(0)