`
cloudtech
  • 浏览: 4722588 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

HttpServletRequest request=ServletActionContext.getRequest();

 
阅读更多
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;
}



}
分享到:
评论

相关推荐

    Struts2的Action中获得request response session几种方法

    private HttpServletRequest request = ServletActionContext.getRequest(); private HttpServletResponse response = ServletActionContext.getResponse(); private HttpSession session = ServletActionContext...

    Struts2_TypeConvertion

    HttpServletRequest request = ServletActionContext.getRequest (); B.ActionContext ct= ActionContext.getContext() HttpServletRequest request= (HttpServletRequest)ct.get(ServletActionContext. ...

    struts2中action如何获取jsp页面参数1.pdf

    HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); HttpSession session = ServletActionContext.getRequest().getSession...

    google translate api 0.95

    HttpServletRequest request = ServletActionContext.getRequest (); String sourceLan = request.getParameter("source"); String targetLan = request.getParameter("target"); String q = request....

    ActionContext在struts2.0中的详细应用

    HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` 在选择使用ActionContext还是ServletActionContext时,优先考虑...

    Struts2下载文件中文乱码处理

    HttpServletRequest request = ServletActionContext.getRequest(); String userAgent = request.getHeader("User-Agent"); if (userAgent.contains("MSIE")) { // IE this.fileName = URLEncoder.encode(this....

    struts2 中action 如何获取jsp 页面参数1.pdf

    HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` `ServletActionContext`提供了如下几个对象的访问接口: 1. `...

    struts2的学习笔记+测试源代码

    HttpServletRequest request = ServletActionContext.getRequest(); // 获取请求参数 String parameter = request.getParameter("paramName"); // ... } } ``` ### session对象 `HttpSession`对象用于在用户...

    struts2访问request,session,application作用域

    HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getSession(); ServletContext application = ServletActionContext.getServletContext(); ``` **2...

    使用struts的同步令牌避免form的重复提交

    HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); String token = UUID.randomUUID().toString(); session.setAttribute("token", token); // ...

    ActionContext介绍(在Struts2中)

    HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = ServletActionContext.getRequest().getSession(); ``` **选择使用ActionContext还是ServletActionContext** 在选择使用...

    Struts2在Action中获得Response对象的四种方法

    HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); // 使用request和response进行操作 return SUCCESS; } } ``` 以上...

    struts2中request和session的获取

    这里通过`ServletActionContext.getRequest()`直接获取到了`HttpServletRequest`对象,这是一种常用的获取request对象的方式。 ### Session对象的理解与获取方式 #### Session对象的作用 Session对象用于存储...

    Struts2访问ServletAPI

    HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); ``` 这样,你可以利用`HttpServletRequest`和`HttpServletResponse`...

    STRUTS2获得作用域、参数响应对象及三种符号说明

    HttpServletRequest request = ServletActionContext.getRequest(); // 方法B ActionContext context = ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest) context.get...

    java传值中的乱码

    - `ServletActionContext.getRequest()`用于获取当前HttpServletRequest对象,从而可以从中获取请求参数。 - `getParameter("key")`获取名为"key"的参数值。 - `URLDecoder.decode()`方法用来对参数进行解码,第...

    struts2.1文档

    HttpServletRequest request = ServletActionContext.getRequest(); ServletContext servletContext = ServletActionContext.getServletContext(); request.setAttribute("req", "请求范围属性"); // 存储到请求...

Global site tag (gtag.js) - Google Analytics