Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Servlet使用和实现Head、Option、Trace http方法_Java_Forms_Http_Servlets_Web - Fatal编程技术网

Java 使用Servlet使用和实现Head、Option、Trace http方法

Java 使用Servlet使用和实现Head、Option、Trace http方法,java,forms,http,servlets,web,Java,Forms,Http,Servlets,Web,我想通过使用Servlet实现以下方法来了解它们的工作原理 doHead() doTrace() doHead() doOption() doDelete() 每个教程和文档都给出了语法和理论意义,但我没有找到它们的实际用法和实现 u plz可以帮助我解决使用这些方法和实际实现代码的场景吗 我试图从html表单调用这些函数,并实现了相应的方法,但它不起作用 <form action="trace" method="trace"> <input type="subm

我想通过使用Servlet实现以下方法来了解它们的工作原理

doHead()  
doTrace()  
doHead()  
doOption()
doDelete()
每个教程和文档都给出了语法和理论意义,但我没有找到它们的实际用法和实现

u plz可以帮助我解决使用这些方法和实际实现代码的场景吗

我试图从html表单调用这些函数,并实现了相应的方法,但它不起作用

<form action="trace" method="trace">
<input type="submit">
</form>
<form action="trace" method="option">
<input type="submit">
</form>

正如@Tpolnik所说,您最好先了解这些HTTP方法的语义。下面是这些方法的简要说明表,摘自


由于大多数现代浏览器不支持使用
GET
POST
以外的方法提交表单,因此使用
TRACE
OPTION
作为将用户数据传输到HTTP服务器的方法是没有意义的。有关更多信息,请参阅。

请参阅HTTP规范,以了解HTTP请求的一般语义以及每个HTTP方法的具体语义。这些servlet方法只是HTTP标准的反映。我在Wc3文档中也没有找到任何关于这些函数的有用信息。@ShamsuddinAltamash大多数浏览器在按照文档建议提交表单时可能只支持
GET
POST
。我认为您最好尝试选择另一种方式来发出
HEAD
选项
请求,如AJAX或其他http客户端,如Chrome扩展。
+---------+-------------------------------------------------+-------+
| Method  | Description                                     | Sec.  |
+---------+-------------------------------------------------+-------+
| GET     | Transfer a current representation of the target | 4.3.1 |
|         | resource.                                       |       |
| HEAD    | Same as GET, but only transfer the status line  | 4.3.2 |
|         | and header section.                             |       |
| POST    | Perform resource-specific processing on the     | 4.3.3 |
|         | request payload.                                |       |
| PUT     | Replace all current representations of the      | 4.3.4 |
|         | target resource with the request payload.       |       |
| DELETE  | Remove all current representations of the       | 4.3.5 |
|         | target resource.                                |       |
| CONNECT | Establish a tunnel to the server identified by  | 4.3.6 |
|         | the target resource.                            |       |
| OPTIONS | Describe the communication options for the      | 4.3.7 |
|         | target resource.                                |       |
| TRACE   | Perform a message loop-back test along the path | 4.3.8 |
|         | to the target resource.                         |       |
+---------+-------------------------------------------------+-------+