Struts2学习笔记

首先说明我是根据struts-2.3.37版本来学习的,之后的2.5版本我以后会做补充

  1.  框架:是一个半成品,完成了一部分代码,可以在其基础上再次开发
  2.  struts2框架:是web层使用的mvc框架
  3.  struts2核心:struts核心和xwork核心
  4.  struts2入门          

                              1. 导入jar包

                                        

                              2 . struts.xml位于src下(clasess)

                              3 . struts.xml文件中的标签

                                          <package>用于管理action

                                                  name:包名,唯一

                                                  namespace:与action的name属性确定访问action的路径       默认值为空

                                                  extends:继承的包名         一般是struts-default

                                                  abstact:值为true/false,代表是否可以被继承

                                         <action>声明一个action

                                                  name:名称,同一包下不能重名

                                                  class:action类全路径,默认值为:ActionSupport

                                                  method:action中的方法 返回String    默认值:execute()方法

                                        <result>结果视图

                                                  name:与action中的method中的返回值匹配跳转

                                                  type:跳转方式        在struts-default.xml中定义

                                                                                  chain:请求转发,跳到另一个action

                                                                                  dispatcher:请求转发,跳到一个jsp页面

                                                                                  redirect:重定向 ,跳到一个jsp页面

                                                                                  redirectAction:重定向 ,跳到一个action

                                                                                  stream:用于下载

    5 . struts2框架加载配置文件顺序

           1 . default.properties        --加载struts2框架中用到的常量

           2.struts-default.xml (bean,interceptor,结果类型)          struts-plugin.xml   (插件)       struts.xml

           3. struts.properties(自定义常量,一般不用)

           4 . web.xml

  6 . 定义常量

           1 . struts.xml

           2 .struts.properties

           3 . web.xml

  7  . action 的创建方式

          1 . POJO类(普通Java类)

          2 . implements Action

          3 .extends ActionSupport

   8 . struts中的 action方法的访问方式

           1 . method=xxx

           2 . 通配符

           3 .动态方法调用

    9 . 关于在struts2中获取Servlet  API

           1 .ActionContext

                  ActionContext    context = ActionContext.getContext();

           2 .使用注入

           3 . ServletActionContext 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值