gpt4 book ai didi

post - 如何知道 Struts 2 操作中的 HTTP 请求是 GET 还是 POST?

转载 作者:行者123 更新时间:2023-12-03 08:31:20 25 4
gpt4 key购买 nike

有没有办法在 Struts2 操作的方法中知道这是 GET 还是 POST 请求?

最佳答案

你的行动应该实现 org.apache.struts2.interceptor.ServletRequestAware ,所以你的 Action 类应该有类似的东西

private HttpServletRequest httpRequest;
// ...
public void setServletRequest(HttpServletRequest request) {
this.httpRequest = request;
}

然后就这样做:
 String method = httpRequest.getMethod() ;

关于post - 如何知道 Struts 2 操作中的 HTTP 请求是 GET 还是 POST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2927864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com