springBoot 版本 2.0.4.RELEASE
当参数含有特殊符号 [] 报错400
解决方案类似springMvc修改tomcat配置,springBoot 启动类中添加 bean
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class SigncallbackApplication {
public static void main(String[] args) {
SpringApplication.run(SigncallbackApplication.class, args);
}
@Bean
public TomcatServletWebServerFactory tomcatServletWebServerFactory (){
// 修改内置的 tomcat 容器配置
TomcatServletWebServerFactory tomcatServlet = new TomcatServletWebServerFactory();
tomcatServlet .addConnectorCustomizers(
(TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "[]{}")
);
return tomcatServlet ;
}
}
XXXController1.java
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
/**
* @author: ma dengling
* @create: 2020-04-13 11:09
* @Desc:
*/
@RestController
@RequestMapping(value = {"/signcallback1"})
public class TpnHtqzLogController1 {
private static final Logger log = LoggerFactory.getLogger(TpnHtqzLogController1.class);
@RequestMapping(value = "/htqz_log")
public String htqzLog(String jsonString) {
log.info(jsonString);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
String callBackAction = jsonObject.getString("action");
return callBackAction;
}
}
postman调用接口
控制台输出结果