Coding forward and backward slashes in tomcat 7?

匿名 (未验证) 提交于 2019-12-03 02:51:02

问题:

I try send request like http://site.com/abc%2Fabc and it doesn't work (send status 400). How I understand tomcat doesn't accept encoded path separators for security reasons, but I don't know how to enable this coding. (I have found only option AllowEncodedSlashes for apache http server). Can you help me?

UPDATE

I fixed this trouble using tiny hack - before render replace all '/' characters on '|' and after reverse this characters on '/'

回答1:

There is a Tomcat option to allow encoded path separators.

Set the CATALINA_OPTS env var to

-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true 

This will allow encoded slashes.



回答2:

We can also add this entry "org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true" in catalina.properties to allow encoded slash in url.


And to allow backslash you have to set different properties. Refer this url for different configuration.



回答3:

Have you tried putting URIEncoding="UTF-8" in your <Connector in the server.xml?



回答4:

To make this workable for my by editing $CATALINA_HOME\conf\server.xml

Old Value: <Connector ... protocol="HTTP/1.1"... />

New Value: <Connector ... protocol="HTTP/1.1"... relaxedQueryChars='\ { } |' />

I am using Tomcat 7.0.88



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!