首页 > 技术文章 > struts2区分get/post请求

xingyyy 2014-03-31 20:29 原文

1

/**
* Struts2判断GET/POST请求
*/
String method = ServletActionContext.getRequest().getMethod();
System.out.println(method);
if (method.equals("POST")) {// 注意全部大写
System.out.println("POST请求");
} else {
System.out.println("GET请求");
}

 

 2、当服务器上跑一个工程时,访问index.jsp的方法是get方法

Done

推荐阅读