1.使用ActionContext类

//1获取ActionContext对象
ActionContext context = ActionContext.getContext();
//2.调用方法获取key-value值
Map<String, Object> map = context.getParameters();
Set<String> set = map.keySet();
for(String key :set){
Object[] o = (Object[]) map.get(key);
System.out.println(Arrays.toString(o));
}

2.使用ServletActionContext类

//使用ServletActionContext对象获取request对象
HttpServletRequest request = ServletActionContext.getRequest();
//2.使用request对象获取表单数据
String username = request.getParameter("username");
String password = request.getParameter("password");
String address = request.getParameter("address");
System.out.println("username="+username);
System.out.println("password"+password);
System.out.println("address"+address);

3.实现ServletRequestAware接口

public class FormDemo3Action extends ActionSupport implements ServletRequestAware {
HttpServletRequest httpServletRequest;
@Override
public void setServletRequest(HttpServletRequest httpServletRequest) {
this.httpServletRequest=httpServletRequest;
}
@Override
public String execute(){
String username = httpServletRequest.getParameter("username");
String password = httpServletRequest.getParameter("password");
System.out.println("username="+username);
System.out.println("password="+password);

return NONE;
}
}