【问题标题】:Servlets response based on content types基于内容类型的 Servlet 响应
【发布时间】:2014-12-07 04:14:27
【问题描述】:

在调试我的服务器时,我遇到了这个问题:

当http post header是

headers: {'Content-Type': 'application/x-www-form-urlencoded',}    

servlet 后断点已激活

当http post header是

headers: {'Content-Type': 'application/json',}      

servlet post 断点未激活,请求“无处可去”。

为什么会这样?是否有默认过滤器或类似的东西?

谢谢!

【问题讨论】:

    标签: http servlets http-headers http-post content-type


    【解决方案1】:

    我遇到了类似的问题。我认为了解正在发生的事情的最佳资源是 servlet 规范。

    见第44 来自 Servlet API 规范:

    http://download.oracle.com/otndocs/jcp/servlet-3_1-fr-eval-spec/index.html

    以下是必须的条件 在发布表单数据之前满足 填充到参数集:

    1. 请求是 HTTP 或 HTTPS 请求。
    2. HTTP 方法是 POST。
    3. 内容类型为 application/x-www-form-urlencoded
    4. servlet 已对任何 请求对象上的 getParameter 方法族。

    如果条件不满足,发帖 rm 数据不包含在参数中 设置,帖子数据必须仍然可用 通过请求对象的输入到 servlet 溪流。如果条件满足,发帖 rm 数据将不再可用于 直接从请求对象的输入流中读取

    【讨论】:

      猜你喜欢
      • 2014-10-07
      • 1970-01-01
      • 2017-09-17
      • 2019-11-04
      • 2015-03-10
      • 2011-01-21
      • 2010-09-28
      • 2019-01-01
      • 1970-01-01
      相关资源
      最近更新 更多