1.通过ServletActionContext类

//获取request对象
HttpServletRequest request = ServletActionContext.getRequest();
//保存值到application中
ServletActionContext.getActionContext(request).setApplication(new HashMap<>());

2.通过ServletRequestAware 接口

    public class UserAction extends ActionSupport implements ServletRequestAware {

    private String username;

    private String userpwd;

    private HttpServletRequest request;

    public String getUsername() {
return username;
} public void setUsername(String username) {
this.username = username;
} public String getUserpwd() {
return userpwd;
} public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
} @Override
public void setServletRequest(HttpServletRequest arg0) { this.request = arg0;
} public void executeAjax() throws IOException { // 处理Ajax请求 String name = request.getParameter("username"); String pwd = request.getParameter("userpwd"); HttpServletResponse response = ServletActionContext.getResponse(); response.getWriter().print("hello"+username+"hello"+userpwd); } }

最新文章

  1. asp.net 生成 excel导出保存时, 解决迅雷下载aspx页面问题
  2. mvc+ef中比较数据
  3. Android开发指南-框架主题-安全和许可
  4. MJRefresh插件引起的错误
  5. Astyle:代码格式化工具简明指南
  6. Android基础知识巩固:关于PendingIntent和广播
  7. Python开发规范
  8. 汉化DevExpress
  9. 14、Redis的复制
  10. golang sqrt error练习
  11. hive 下篇
  12. 不同tab下的列表长度不同,tab的样式和底部的位置不同
  13. Spring中常用的注解(@Entity,@Table,@Column,@Repository,@Service)
  14. 201621123010《Java程序设计》第3周学习总结
  15. Linux环境编程之IPC进程间通信(五):Posix消息队列1
  16. Selenium2+python自动化-操作浏览器基本方法
  17. Spring AOP 整理
  18. SDOI2012 Round1 day2 集合(set)解题报告
  19. 零基础学 JavaScript 全彩版 明日科技 编著
  20. vue项目设置每个页面的title

热门文章

  1. 用jquery制作的简单轮播图
  2. Vue动态注册异步组件(非同一个工程的组件)
  3. STM32之模拟串口设计
  4. springMvc几个常用注解
  5. Manjaro美化 配置教程
  6. NTP时间服务器构建
  7. 实验查看PHP本地的Session信息
  8. mysql的mod函数
  9. [POI2008]BLO(Tarjan)
  10. centos6.5安装nginx1.16.0