package app.converter;
import java.util.Collection;
import java.util.Date;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport {
private Integer id;
private String username;
private Date createtime;
private Education edu;
private Collection<Emp>emps;
public String save(){
System.out.println("UserAction tfy save()");
HttpServletRequest request=ServletActionContext.getRequest();
//获取web页面元素
String id=request.getParameter("id");
String usename=request.getParameter("username");
System.out.println("id=="+id);
System.out.println("username=="+username);
System.out.println("createtime=="+createtime);
System.out.println(edu.getEduid()+"=="+edu.getEduname());
return SUCCESS;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public Education getEdu() {
return edu;
}
public void setEdu(Education edu) {
this.edu = edu;
}
public Collection<Emp> getEmps() {
return emps;
}
public void setEmps(Collection<Emp> emps) {
this.emps = emps;
}
}
分享到:
相关推荐
private HttpServletRequest request = ServletActionContext.getRequest(); private HttpServletResponse response = ServletActionContext.getResponse(); private HttpSession session = ServletActionContext...
HttpServletRequest request = ServletActionContext.getRequest (); B.ActionContext ct= ActionContext.getContext() HttpServletRequest request= (HttpServletRequest)ct.get(ServletActionContext. ...
HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); HttpSession session = ServletActionContext.getRequest().getSession...
HttpServletRequest request = ServletActionContext.getRequest (); String sourceLan = request.getParameter("source"); String targetLan = request.getParameter("target"); String q = request....
HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` 在选择使用ActionContext还是ServletActionContext时,优先考虑...
HttpServletRequest request = ServletActionContext.getRequest(); String userAgent = request.getHeader("User-Agent"); if (userAgent.contains("MSIE")) { // IE this.fileName = URLEncoder.encode(this....
HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` `ServletActionContext`提供了如下几个对象的访问接口: 1. `...
HttpServletRequest request = ServletActionContext.getRequest(); // 获取请求参数 String parameter = request.getParameter("paramName"); // ... } } ``` ### session对象 `HttpSession`对象用于在用户...
HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getSession(); ServletContext application = ServletActionContext.getServletContext(); ``` **2...
HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); String token = UUID.randomUUID().toString(); session.setAttribute("token", token); // ...
HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` **选择使用ActionContext还是ServletActionContext** 在选择使用...
HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); // 使用request和response进行操作 return SUCCESS; } } ``` 以上...
这里通过`ServletActionContext.getRequest()`直接获取到了`HttpServletRequest`对象,这是一种常用的获取request对象的方式。 ### Session对象的理解与获取方式 #### Session对象的作用 Session对象用于存储...
HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); ``` 这样,你可以利用`HttpServletRequest`和`HttpServletResponse`...
HttpServletRequest request = ServletActionContext.getRequest(); // 方法B ActionContext context = ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest) context.get...
- `ServletActionContext.getRequest()`用于获取当前HttpServletRequest对象,从而可以从中获取请求参数。 - `getParameter("key")`获取名为"key"的参数值。 - `URLDecoder.decode()`方法用来对参数进行解码,第...
HttpServletRequest request = ServletActionContext.getRequest(); ServletContext servletContext = ServletActionContext.getServletContext(); request.setAttribute("req", "请求范围属性"); // 存储到请求...