2017-04-04 290 views
0

我需要允许通过XAMPP安装的Tomcat上的PUT请求。我在网上找到各种答案,但没有人为我工作。 我想在我的项目的web.xml添加以下代码:Tomcat不允许PUT请求

<security-constraint> 
<web-resource-collection> 
    <web-resource-name>allow</web-resource-name> 
    <url-pattern>/*</url-pattern> 
    <http-method>GET</http-method> 
    <http-method>POST</http-method> 
    <http-method>PUT</http-method> 
</web-resource-collection> 
<!-- no auth-constraint tag here --> 

我还试图修改服务器的Tomcat的web.xml:

<servlet> 
    <servlet-name>default</servlet-name> 
    <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-  class> 
    <init-param> 
     <param-name>debug</param-name> 
     <param-value>0</param-value> 
    </init-param> 
    <init-param> 
     <param-name>listings</param-name> 
     <param-value>false</param-value> 
    </init-param> 
    <init-param> 
     <param-name>readonly</param-name> 
     <param-value>false</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

但每次PUT仍然没有按”工作。在Postman上进行测试,响应状态为204,但该方法未执行。 你能帮我吗?

回答

0
<security-constraint> 
<web-resource-collection> 
    <web-resource-name>allow</web-resource-name> 
    <url-pattern>/*</url-pattern> 
    <http-method>GET</http-method> 
    <http-method>POST</http-method> 
    <http-method>PUT</http-method> 
</web-resource-collection> 
<!-- no auth-constraint tag here --> 

这些限制或“限制”可以执行的方法。只在这里添加你不想允许的。