您的位置:首页 >> 编程开发 >> Java >> Struts/Hibernate >> 正文
Struts/Hibernate RSS
 

struts 2 学习相关

http://www.rdxx.com 08年06月19日 00:00 我要投稿

关键词: Struts , 学习

    struts2 学习

    一。 核心文件struts.xml 的配置

      1。 bean的配置

          主要就是名字的一个引用

    <struts>

      <bean type="com.opensymphony.xwork2.ObjectFactory" name="myfactory" class="com.company.myapp.MyObjectFactory" />

      ...

    </struts>The bean element has one required attribute, class, which specifies the Java class to be created or manipulated. A bean can either be created by the framework's container and injected into internal framework objects, or have values injected to its static methods The first use, object injection, is generally accompanied by the type attribute, which tells the container which interface this object implements. The second use, value injection, is good for allowing objects not created by the container to receive framework constants. Objects using value inject must define the the static attribute.Attribute  Required  Description  class  yes  the name of the bean class  type  no  the primary Java interface this class implements  name  no  the unique name of this bean; must be unique among other beans that specify the same type  scope  no  the scope of the bean; must be either default, singleton, request, session, thread  static  no  whether to inject static methods or not; shouldn't be true when the type is specified  optional  no  whether the bean is optional or not 3 Packages的配置简单就包的配置 是配置的一个逻辑规划Attribute  Required  Description  name  yes  key to for other packages to reference  extends  no  inherits package behavior of the package it extends  namespace  no  see Namespace Configuration  abstract  no  declares package to be abstract (no action configurations required in package) Sample usage Package Example (struts.xml)<struts>
      <package name="employee" extends="struts-default" namespace="/employee">
        <default-interceptor-ref name="crudStack"/>

        <action name="list" method="list"
          class="org.apache.struts2.showcase.action.EmployeeAction" >
            <result>/empmanager/listEmployees.jsp</result>
            <interceptor-ref name="basicStack"/>
        </action>
        <action name="edit-*" class="org.apache.struts2.showcase.action.EmployeeAction">
          <param name="empId">{1}</param>
          <result>/empmanager/editEmployee.jsp</result>
            <interceptor-ref name="crudStack">
              <param name="validation.excludeMethods">execute</param>
            </interceptor-ref>
          </action>
          <action name="save" method="save"
              class="org.apache.struts2.showcase.action.EmployeeAction" >
            <result name="input">/empmanager/editEmployee.jsp</result>
            <result type="redirect">edit-${currentEmployee.empId}.action</result>
          </action>
          <action name="delete" method="delete"
            class="org.apache.struts2.showcase.action.EmployeeAction" >
            <result name="error">/empmanager/editEmployee.jsp</result>
            <result type="redirect">edit-${currentEmployee.empId}.action</result>
          </action>
      </package>
    </struts>


 

共3页  1 2 3


 
 
标签: Struts , 学习 打印本文
 
 
  热点搜索
 
 
 


Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站