2017-04-04 225 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 --> 

這些限制或「限制」可以執行的方法。只在這裏添加你不想允許的。