Skip to content

Instantly share code, notes, and snippets.

@thiagofa
Created October 30, 2019 21:08
Show Gist options
  • Save thiagofa/ce48c08e4caae34c5dca0a7a5c252666 to your computer and use it in GitHub Desktop.
Save thiagofa/ce48c08e4caae34c5dca0a7a5c252666 to your computer and use it in GitHub Desktop.
Customiza Tomcat embedado do Spring Boot para aceitar colchetes nas URLs
// Referências:
// - https://stackoverflow.com/a/53613678
// - https://tomcat.apache.org/tomcat-8.5-doc/config/http.html
// - https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-webserver
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
@Component
public class TomcatCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
@Override
public void customize(TomcatServletWebServerFactory factory) {
factory.addConnectorCustomizers(connector -> connector.setAttribute("relaxedQueryChars", "[]"));
}
}
@diorgenesmorais
Copy link

Olá Thiago, sei que esse código é apenas uma alternativa...
O método 'setAttribute' está depreciado, eu usei aqui o 'setProperty' no lugar.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment