您的位置:首页 > 其它

为什么2007是金猪年???

2008-01-03 09:59 381 查看
 struts2 的demo 中的employee层可以清晰的暂时struts希望给开发者带来的架构
--------------------------
EmployeeAction <-- AbstractCRUDAction (web 层)
   ^
   |
EmployeeDao <-- AbstractDao <-- Dao (Domain 层,demo中也作为service存在于spring容器中)
   ^
   |
Employee <--IDEntity
--------------------------
struts.xml 配置
   
       
       
            /empmanager/listSkills.jsp
           
       
       
            /empmanager/editSkill.jsp
           
           
       
       
            /empmanager/editSkill.jsp
            edit.action?skillName=${currentSkill.name}
       
       
            /empmanager/editSkill.jsp
            edit.action?skillName=${currentSkill.name}  这里展现了struts2具有良好的url特性,比起ww的crud!edit让人舒服多了
       
   
   
       
       
            /empmanager/listEmployees.jsp
           
       
       
         {1}
            /empmanager/editEmployee.jsp
            execute
       
       
            /empmanager/editEmployee.jsp
            edit-${currentEmployee.empId}.action
       
       
            /empmanager/editEmployee.jsp
            edit-${currentEmployee.empId}.action
       
   
   
-----------------------------
每一个action有自己的properties文件,非常便于管理和代码生成,
当然也有一个全局的globalMessages.properties来存放一些save,delete这些都一样的字符
employee=Employee
employee.firstName=First Name
employee.lastName=Last Name
employee.description=Description
employee.id.required=Id is required
employee.lastName.required=Last Name is required
employee.birthDate.required=Birthdate is required
employee.backtolist=Back to Employee List
每个action自己的validation

http://www.opensymphony.com/xwork/xwork-validator-1.0.dtd">

   
   
       
           
       
   
   
       
            true
           
       
   
   
       
           
       
   

--------------------------------
DAO是spring的bean,spring默认作为struts2的业务组件容器
在struts.properties中struts.objectFactory = spring
由于这里是autowire,Autowiring means to look for objects defined in Spring with the same name as your object property
所以action中所有用到IoC的地方,都会自动注入(因为action本质也是bean,下面会讲到)
wire有四种方法:name, type, auto, constructor
   
   
   
----------------------------------
struts2中的每一个action,也就是struts.xml里面声明的action,最终都将作为spring中的一个bean完成请求。
如果你不做额外的设定,struts2会自动生成这个bean。
如果你有特殊的需要,还可以在applicationContext.xml自己声明这个bean
你必须根据需要来决定是否再次声明
struts.xml
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

   
   
          这个foo,在applicationConext.xml中没有声明,struts会自动生成一个bean
            foo.ftl
       
   
   
                   这个foo,在applicationConext.xml中声明了,struts会使用下面配置
            bar.ftl
       
   

applicationConext.xml

http://www.springframework.org/dtd/spring-beans.dtd">

   
    ...

-------------------------
无缝集成ajax
只要声明了theme="ajax",该标签控件的操作就被转换成ajax,请求发送到AjaxRemoteForm
Configured Editor configuration:

   
        textGroup;|;justifyGroup;|;listGroup;|;indentGroup
   
   

------------------------
集成了多种模板
jsp,velocity,freemaker

------------------------
struts2 继承了ww2的优良传统,并且摈弃了ww2的一些缺陷,也可以看成是对ww2的一次重购。
无疑是目前最主流,最强大的MVC框架了。
它实现了和spring的完美结合
集成了ajax(dojo+dwr)
其插件支持jasperreports,jfreechart

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1504218
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: