摘要: struts2里面不使用ActionForm来接收参数,而是在Action中定义一个与请求参数同名的属性就能接收到表单中的参数。jsp页面上通过el表达式来取得Action中属性的值。如果在一个类中包含了另一个类作为参数,那么在form表单中定义属性名称的时候就需要使用对象来指定了,比如form中的input的name为Person.id,在el中也要使用Person.id获取数据。struts2中有两种类型转换器:1,局部类型转换器:定义类型转换器:package control.center;import java.sql.Date;import java.text.ParseExcept 阅读全文
posted @ 2011-02-23 23:54 魔战 阅读(193) 评论(0) 推荐(0)
摘要: 用户请求后,filter拦截请求,匹配请求然后经过struts2的拦截器,在进入action,在Action中处理,然后返回return result返回。struts1与struts2的不同:struts2为用户的每一次请求都会创建一个Action,所以struts2中的Action是线程安全;struts1的Action创建之后放在了缓存中,一直存在,只有一个实例。为了避免struts.xml文件过于大而臃肿,可以将一个struts.xml配置文件分解成多个配置文件,然后再struts.xml文件中包含其他配置文件。<include file="struts-user.xm 阅读全文
posted @ 2011-02-23 22:19 魔战 阅读(280) 评论(0) 推荐(0)
摘要: 类:package control.center;import java.net.URLEncoder;public class HelloWordAction {private String savePath;public String getSavePath() {return savePath;}public void setSavePath(String savePath) {this.savePath = savePath;}public String execute() throws Exception{URLEncoder.encode("星期三"," 阅读全文
posted @ 2011-02-23 21:48 魔战 阅读(440) 评论(0) 推荐(0)
摘要: struts2在webwork2基础发展而来,struts2与struts1相比,没有跟ServletAPI和struts API有着紧密的耦合,struts2为无侵入式设计,而struts1却属于侵入式设计;struts2提供了拦截器,利用拦截器可以进行AOP编程,实现如权限拦截等功能;struts2提供了类型转换器,struts1的数据类型转换是通过BeanUtil来实现的。struts2在StrutsPrepareAndExcuteFilter的init()方法中将读取类路径下默认的配置文件struts.xml完成初始化操作,读取struts.xml的内容后,以javabean形式存放在 阅读全文
posted @ 2011-02-23 21:03 魔战 阅读(477) 评论(0) 推荐(0)