package com.gxwebsoft.common.core.config;

import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Tomcat 配置类，用于解决 URL 中包含特殊字符的问题
 */
@Configuration
public class TomcatConfig {
    
    /**
     * 允许 URL 中包含特殊字符（如中文、括号等）
     * 解决错误：Invalid character found in the request target
     */
    @Bean
    public TomcatConnectorCustomizer tomcatConnectorCustomizer() {
        return connector -> {
            // 允许 [] 等特殊字符
            connector.setProperty("relaxedPathChars", "[]|{}^<>\"");
            connector.setProperty("relaxedQueryChars", "[]|{}^<>\"\\`");
        };
    }
}
