Commit 7275c1fcd53a5bd37a999573662e52714c11eb9c
1 parent
24b52a70
修复tomcat服务器已知问题
Showing
2 changed files
with
28 additions
and
2 deletions
src/main/java/com/cnlive/shenhe/ShenheApplication.java
| 1 | 1 | package com.cnlive.shenhe; |
| 2 | 2 | |
| 3 | +import org.apache.catalina.connector.Connector; | |
| 3 | 4 | import org.jasig.cas.client.authentication.AuthenticationFilter; |
| 4 | 5 | import org.jasig.cas.client.session.SingleSignOutFilter; |
| 5 | 6 | import org.jasig.cas.client.util.AssertionThreadLocalFilter; |
| ... | ... | @@ -11,7 +12,10 @@ import org.springframework.beans.factory.annotation.Value; |
| 11 | 12 | import org.springframework.boot.ApplicationRunner; |
| 12 | 13 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 13 | 14 | import org.springframework.boot.builder.SpringApplicationBuilder; |
| 15 | +import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; | |
| 16 | +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | |
| 14 | 17 | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| 18 | +import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; | |
| 15 | 19 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
| 16 | 20 | import org.springframework.context.annotation.Bean; |
| 17 | 21 | import org.springframework.context.annotation.Configuration; |
| ... | ... | @@ -51,6 +55,26 @@ public class ShenheApplication extends SpringBootServletInitializer { |
| 51 | 55 | @Value("${SERVICE_LOGINOUT}") |
| 52 | 56 | private String SERVICE_LOGINOUT; |
| 53 | 57 | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 解决异常信息: | |
| 61 | + * java.lang.IllegalArgumentException: | |
| 62 | + * Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 | |
| 63 | + * @return | |
| 64 | + */ | |
| 65 | + @Bean | |
| 66 | + public ConfigurableServletWebServerFactory webServerFactory() { | |
| 67 | + TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); | |
| 68 | + factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { | |
| 69 | + @Override | |
| 70 | + public void customize(Connector connector) { | |
| 71 | + connector.setProperty("relaxedQueryChars", "|{}[]/`\\<>"); | |
| 72 | + connector.setProperty("relaxedPathChars", "|{}[]/`\\<>"); | |
| 73 | + } | |
| 74 | + }); | |
| 75 | + return factory; | |
| 76 | + } | |
| 77 | + | |
| 54 | 78 | public static void main(String[] args) { |
| 55 | 79 | SpringApplicationBuilder builder = new SpringApplicationBuilder(ShenheApplication.class); |
| 56 | 80 | builder.headless(true).run(args); | ... | ... |
src/main/resources/application.properties
| ... | ... | @@ -6,8 +6,10 @@ spring.thymeleaf.encoding=UTF-8 |
| 6 | 6 | spring.thymeleaf.servlet.content-type=text/html |
| 7 | 7 | spring.thymeleaf.cache=false |
| 8 | 8 | |
| 9 | -server.tomcat.max-http-post-size=-1 | |
| 10 | -server.max-http-header-size=10240 | |
| 9 | +# \u5F02\u5E38\u4E00\uFF1AInvalid character found in method name. HTTP method names must be token | |
| 10 | +#\u539F\u56E0\uFF1A \u4EA7\u751F\u8FD9\u4E2A\u95EE\u9898\u7684\u539F\u56E0\u662F\u9875\u9762\u8868\u5355\u63D0\u4EA4\u4E86\u5927\u91CF\u7684\u6570\u636E\uFF0C\u800C\u8FD9\u4E9B\u6570\u636E\u91CF\u53EF\u80FD\u8D85\u8FC7\u4E86Tomcat \u5B9A\u4E49\u7684Header\u5934\u5185\u5BB9\uFF0C\u53EA\u8981\u8BBE\u7F6E\u4E00\u4E0BTomcat\u7684maxHttpHeaderSize | |
| 11 | +server.tomcat.max-http-post-size=10240000 | |
| 12 | +server.max-http-header-size=10240000 | |
| 11 | 13 | |
| 12 | 14 | server.tomcat.protocol_header=x-forwarded-proto |
| 13 | 15 | server.use-forward-headers=true | ... | ... |