Java – escape slashes in HTTP requests

I execute HTTP delete requests from JavaScript to Java Web applications The web application uses Jersey to send web addresses The tricky thing is that I'm using path parameters with forward slashes (such as "XX / 6666") When I run it in Jetty (Maven plug-in), it works normally, but when I run it on my production server (Tomcat), it doesn't, that is, I get 404

Use / escape forward slashes, so my request URL looks like

Delete http: / /... / 4776 / shipmentorders / XX / 6666

Does this allow jetty and Tomcat to interpret these in different ways in the HTTP specification?

Solution

Tomcat (I think in versions 5, 6 and 7) purposefully prevents the use of / in the path to prevent directory traversal attacks It is said that you can set org. Org apache. tomcat. util. BUF to turn off this protection UDecoder. ALLOW_ ENCODED_ Lash = true I didn't test it myself, but I saw other people on the Internet claim that it has solved the problem for them However, please note that the web server in front of Tomcat may also intercept and rewrite the URL and automatically decode / forward forward the forward slash

reference resources: http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>