java - httpServletRequest.getParameter 返回 null

标签 java servlets servlet-filters weblogic11g oracle-enterprise-manager

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

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

我停止了vpn来调用本地的,所以他们之间没有干扰。

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

本地在我的电脑上:weblogic server 11g
远程是通过vpn:weblogic enterprise manager

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

第二个为空。

我发送到以下网址:

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"));

        }

我们将不胜感激

最佳答案

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

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

关于java - httpServletRequest.getParameter 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23768735/

相关文章:

java - 将struts web项目升级到java 1.7

java - 如何在 swt.browser 中启用左键单击拖动或右键单击

java - 每次 servlet 发生变化时如何执行 ajax 函数?

java - getSession() 总是创建一个新 session

java - 如何从 HttpServletResponse 获取 HTML 内容?

java - 写 DAO : how to override or implements the interface methods in abstract class?

java - android studio java.lang.NoClassDefFoundError Gson

java - Cookie 显示一些随机值

java - 第二次访问时session变量为null

annotations - Servlet 3.0 注释与 Guice 结合使用