3

我有两台服务器,一台(本地)和另一台(通过 vpn 远程调用)。

在两者上都部署了相同的应用程序。

我停止vpn呼叫本地的,所以他们之间没有干扰。

我试图在 doFilter 方法中获取 servletFilter 中的参数。

本地在我的电脑上:weblogic server 11g
远程通过 vpn:weblogic 企业管理器

在第一种情况下,httpServletRequest.getParameter 返回发布请求的预期值。

在第二个得到空值。

我发送到以下网址:

http://mydomain/myapp/faces/login-return.jspx

发送请求的 html 表单:

<html>

    <body>
          <form  action="https://mydomain/myapp/faces/login-return.jspx"  method="post">
            <input type="hidden" name="param1" value="value1"  />
            <input type="hidden" name="param2" value="value2"  />
            <input type="submit" name="submit" value="Send to server" />
        </form>
    </body>
</html> 

我的 servlet 过滤器中的代码:

    if (isSessionControlRequiredForThisResource(httpServletRequest, getLoginPage())) {

        if(httpServletRequest.getParameter("param1") != null) {
            httpServletRequest.getSession().setAttribute("param1", httpServletRequest.getParameter("param1"));

        }

任何帮助都会得到批准

4

2 回答 2

1

问题是,服务器期待的是https调用而不是http

因此,当我将调用协议更改为https时,它开始像魅力一样收集请求参数!

于 2014-05-24T12:26:07.963 回答
0
 @PostMapping("/cookies")
func(HttpServletRequest request) {

        Cookie[] cookies = request.getCookies();
        
         if (cookies != null) {
            //ive goten always null
         }

   }

“PostMapping(”/cookies“)”上方的错误将其更改为“GetMapping(”/cookies”)”一切开始工作。它的`导致函数无法在没有任何主体的情况下读取 post hhtp 请求中的 cookie,如果你没有向后端发送任何数据而不是使用 get 方法 insted。

于 2021-11-26T13:00:50.967 回答