Commit 70b0abe2fec84d2309efc58a597e2acb6e7b3797

Authored by 王言钊
2 parents 8bea6e86 7275c1fc

Merge branch 'dev'

src/main/java/com/cnlive/shenhe/ShenheApplication.java
1 package com.cnlive.shenhe; 1 package com.cnlive.shenhe;
2 2
  3 +import org.apache.catalina.connector.Connector;
3 import org.jasig.cas.client.authentication.AuthenticationFilter; 4 import org.jasig.cas.client.authentication.AuthenticationFilter;
4 import org.jasig.cas.client.session.SingleSignOutFilter; 5 import org.jasig.cas.client.session.SingleSignOutFilter;
5 import org.jasig.cas.client.util.AssertionThreadLocalFilter; 6 import org.jasig.cas.client.util.AssertionThreadLocalFilter;
@@ -11,7 +12,10 @@ import org.springframework.beans.factory.annotation.Value; @@ -11,7 +12,10 @@ import org.springframework.beans.factory.annotation.Value;
11 import org.springframework.boot.ApplicationRunner; 12 import org.springframework.boot.ApplicationRunner;
12 import org.springframework.boot.autoconfigure.SpringBootApplication; 13 import org.springframework.boot.autoconfigure.SpringBootApplication;
13 import org.springframework.boot.builder.SpringApplicationBuilder; 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 import org.springframework.boot.web.servlet.FilterRegistrationBean; 17 import org.springframework.boot.web.servlet.FilterRegistrationBean;
  18 +import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
15 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 19 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
16 import org.springframework.context.annotation.Bean; 20 import org.springframework.context.annotation.Bean;
17 import org.springframework.context.annotation.Configuration; 21 import org.springframework.context.annotation.Configuration;
@@ -51,6 +55,26 @@ public class ShenheApplication extends SpringBootServletInitializer { @@ -51,6 +55,26 @@ public class ShenheApplication extends SpringBootServletInitializer {
51 @Value("${SERVICE_LOGINOUT}") 55 @Value("${SERVICE_LOGINOUT}")
52 private String SERVICE_LOGINOUT; 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 public static void main(String[] args) { 78 public static void main(String[] args) {
55 SpringApplicationBuilder builder = new SpringApplicationBuilder(ShenheApplication.class); 79 SpringApplicationBuilder builder = new SpringApplicationBuilder(ShenheApplication.class);
56 builder.headless(true).run(args); 80 builder.headless(true).run(args);
src/main/resources/application.properties
@@ -6,8 +6,10 @@ spring.thymeleaf.encoding=UTF-8 @@ -6,8 +6,10 @@ spring.thymeleaf.encoding=UTF-8
6 spring.thymeleaf.servlet.content-type=text/html 6 spring.thymeleaf.servlet.content-type=text/html
7 spring.thymeleaf.cache=false 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 server.tomcat.protocol_header=x-forwarded-proto 14 server.tomcat.protocol_header=x-forwarded-proto
13 server.use-forward-headers=true 15 server.use-forward-headers=true