struts2的开发步骤:1.先定义一个能发送请求的页面,可以是链接,也可以是表单(form)2.开发action类,struts2对action并没有过多的要求,只要求:a 推荐实现action接口,或继承actionsupport类b 为每个请求参数都提供feild,并为之提供相应的setter...
分类:
其他好文 时间:
2014-10-21 21:26:42
阅读次数:
193
对于格式的验证,我们可以自己写js来验证,当然struts已经封装了验证框架,下面说下我的学习哦。
验证框架分为了服务器端的验证和前台的xml配置验证(这里相当于js),下面先说下服务器端的验证。
1:由于action类继承了ActionSupport这个类,其中这个类又实现了Validateable, ValidationAware接口,
所以我们可以直接的重写validate()这个方法...
分类:
其他好文 时间:
2014-10-19 09:03:31
阅读次数:
194
在我们接收页面传来的数据时,这些数据都是以String类型接收的,所以要进行数据格式转换,这时候就可以统一为它们进行转换,而且在处理这些数据的类中可以继承ActionSupport类,然后让每一个接收数据并做业务处理的action类继承该类,并调用该类中的数据格式转换方法对接收的数据进行处理。
部分关键代码如下:
/**
* 超类BaseAction 数据格式转换
* @autho...
分类:
其他好文 时间:
2014-10-15 22:51:11
阅读次数:
147
创建项目struts2101403添加jar包commons-fileupload-1.3.jarcommons-io-2.0.1.jarcommons-lang3-3.1.jarfreemarker-2.3.19.jarjavassist-3.11.0.GA.jarognl-3.0.6.jarstruts2-core-2.3.15.1.jarxwork-core-2.3.15.1.jarsrc创建包cn.jbit.strut2101403.web.action创建实体类@Ove..
分类:
其他好文 时间:
2014-10-15 14:46:11
阅读次数:
245
validate()方法验证一个ACTION类继承ActionSupport有何用处?答:在ActionSupport中实现了很多接口,就拿一个来讲,validate()方法,是默认的验证。我们可以在我们的action类中重写一下此方法。比方说验证用户名是否为空。这个方法不需要调用,当S:FORM表...
分类:
其他好文 时间:
2014-10-08 23:40:27
阅读次数:
230
在eclipse中新建项目StrutsDemo1【struts的配置见】struts开发详细文件夹结构例如以下第一种配置方法新建UserActionpackage fzl.user.struts.demo;import com.opensymphony.xwork2.ActionSupport;pu...
分类:
其他好文 时间:
2014-10-04 13:36:36
阅读次数:
261
一、Action配置中的各项默认值
/WEB-INF/page/hello.jsp
1>如果没有为action指定class,默认是ActionSupport。
2>如果没有为action指定method,默认执行action中的execute() 方法。
3>如果没有指定result的name属性,默认值为success。
二、Actio...
分类:
其他好文 时间:
2014-10-01 11:28:41
阅读次数:
186
1.1 直接创建接收的数据类型 1 public class HelloAction extends ActionSupport { 2 3 private String name; 4 private int age;...
分类:
其他好文 时间:
2014-09-26 01:42:28
阅读次数:
201
类型转换失败:若 Action 类没有实现 ValidationAware 接口: Struts 在遇到类型转换错误时仍会继续调用其 Action 方法, 就好像什么都没发生一样.若 Action 类实现类 ValidationAware 接口(一般继承ActionSupport类就可以了,因为这个...
分类:
其他好文 时间:
2014-09-25 13:42:38
阅读次数:
196
public class BaseAction extends ActionSupport implements ModelDriven { private static final long serialVersionUID = 1L; protec...
分类:
其他好文 时间:
2014-09-09 15:20:58
阅读次数:
193