Struts2判断GET/POST请求



Struts2判断GET/POST请求

Struts2判断页面是POST方式提交还是GET方式提交 (2012-12-20 11:43:01)转载▼
标签: 杂谈 分类: SSH

String method = org.apache.struts2.ServletActionContext.getRequest()
.getMethod();
boolean isPostMethod = “POST”.equalsIgnoreCase(method);

if (!isPostMethod) {
System.out.println(“prepare() GET 方式提交”);
} else {
System.out.println(“prepare() POST 方式提交”);
}

/**
* 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请求”);
}

http://blog.csdn.net/l30961171/article/details/7914230