解决java.lang.IllegalArgumentException:The valid characters are defined in RFC 7230 and RFC 3986

解决java.lang.IllegalArgumentException:The valid characters are defined in RFC 7230 and RFC 3986

这个问题是请求的参数有特殊字符,这里可以在后端处理,处理如下:
加入一个配置类即可解决

/**
 * @Author xiaozq
 * @Date 2023/5/29 16:54
 * @Description
 * 解决 java.lang.IllegalArgumentException:The valid characters are defined in RFC 7230 and RFC 3986
 */
@Configuration
public class TomcatConfig {
    @Bean
    public TomcatServletWebServerFactory webServerFactory() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.addConnectorCustomizers((Connector connector) -> {
            connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
            connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
        });
        return factory;
    }
}

你可能感兴趣的:(场景Bug,java,servlet)