【发布时间】:2014-11-16 01:42:06
【问题描述】:
我想向 URL 发送有效载荷超过 255 的 HTTP POST 请求,如图所示
http://127.0.0.1:8080/Application_name
,它应该直接命中一个Servlet,为此我配置了web.xml,如下所示。
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID" version="2.4">
<welcome-file-list>
<welcome-file>Servlet</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Servlet_INTERFACE</servlet-name>
<servlet-class>com.app.package1.Servlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Servlet_INTERFACE</servlet-name>
<url-pattern>/Servlet</url-pattern>
</servlet-mapping>
</web-app>
当我尝试时,所有请求都只是 GET。当我尝试时
http://127.0.0.1:8080/Application_name/Servlet
然后它的工作正常
- 有可能吗?
- 如果是,我该怎么做?
- 别名是一种解决方案
【问题讨论】:
-
如果始终使用 GET,则问题很可能出在您的客户端。你能用你的 http 客户端代码更新问题吗?
-
你用的是什么容器(这曾经是tomcat的一个bug)?您是否尝试在欢迎文件定义中添加尾部斜杠:/Servlet?
标签: web-services http jakarta-ee servlets