Struts

Struts的几种开发方式:

1、  extends ActionSupport 

2、  implements Action  该action来自com.opensy。。。

3、  就是类

三者使用顺序就是,想要数据校验就必须extends Ac…

通配符:

Struts.xml 文件中进行配置:

         <action name=”out_*” class-“” method=”{1}”>//可以配置多个*号

                   <result name=”{1}”>{1}.jsp  可以配置的位置就是如此之多 {2} 就是第二个*号

Struts路径配置原则:

         Namespace=“/a”  他会在/a以及/a以下的文件夹中搜索

struts 常量:

         <content name=”” value=””/>

         改变访问后缀:struts.action.extension “abc,” 访问后缀是abc或者空格

                   在action中不写menthod 默认调用method

                                               不写class   默认调用系统的一个

                                               result       默认是success

                   什么情况下不写class?需要跳转到web-info 下的资源的时候

                   全局视图配置:<global-results> 默认没写的都跳转该配置地址

struts对数据的操作:

         ServletActionContext     耦合,获取地址使用

         ActionContext                      解耦,设置值使用

         implements ResultAware

         自动封装数据

                  <input name=”abc”>

                  获取数据的action private String abc;并get set方法

         上传下载

                   <input type=”file” name=”def”> 还得配置enctype

                   获取上传action

                            private File def;

                            private String defFileName;

                            private String defContentType

                   下载:

                            在配置文件中加入 type=”stream”

                            配置下载方法:去掉get

         自定义装换类型需要继承StrutsTypeConvert

result name=”input”>/error/error.jsp

原文地址:https://www.cnblogs.com/core404/p/5847543.html