1.接收数据
一:struts操作 Servlet API接口方式 HttpServletRequest HttpServletResponse HttpSession ServletContext
1.
HttpServletRequest request = ServletActionContext.getRequest();
2. implements RequestAware
@Override
public void setRequest(Map<String, Object> request) {
this.request = request;
}
3.
ActionContext actionContext = ActionContext.getContext();
actionContext.setSession(session);
二、Struts 接收数据方式
1.HttpServletRequest request = ServletActionContext.getRequest();
String username = request.getParameter("username");
String password = request.getParameter("password");
2.用Action类的属性
private String username;
public void setUsername(String username){
this.username=username;
}
3.implements ModelDriven<User>
private User user = new User();
@Override
public User getModel() {
return user;
}