Hello all,

For legacy reasons in my project based on spring boot 2.2.5 and spring cloud Hoxton.SR4, we should accept non URL encoded character "|" in query string. We had set the "server.tomcat.relaxed-query-chars=|" in order to let coyotte connector accept this non URL encode character. But I am facing an issue with ServletHttpHandlerAdapter -> Failed to get request URL: Illegal character in query How can I deal with illegal caracters in ServletHttpHandlerAdapter like the server.tomcat.relaxed-query-chars do? Thank's

Comment From: s50600822

You can do this


import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

@Component
public class MyTomcatWebServerCustomizer
        implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

    @Override
    public void customize(TomcatServletWebServerFactory factory) {
        factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
                connector.setProperty("relaxedQueryChars", "|");
            }
        });
    }
}

Assuming you are on Tomcat 8, 9 or 10 https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/connector/Connector.html https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/catalina/connector/Connector.html https://tomcat.apache.org/tomcat-10.0-doc/api/org/apache/catalina/connector/Connector.html

(I didn't check older version. It may just work the same way.) tomcat

Comment From: snicoll

@et00448 this looks like a question to me which would be better suited to StackOverflow, and sharing an exception snippet that we don't throw ourselves is not really to be sufficient. If you want support, please share a small sample that we can run ourselves to reproduce the behavior that you've described.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.