spring boot 的内嵌Tomcat 报 The valid characters are defined in RFC 7230 and RFC 3986 之前的解决办法都是在容器中添加
@Bean
public Integer setRfc()
{
// 指定jre系统属性,允许特殊符号, 如{} 做入参,其他符号按需添加。见 tomcat的HttpParser源码。
System.setProperty("tomcat.util.http.parser.HttpParser.requestTargetAllow", "|{}");
return 0;
}
或者在启动类中添加
System.setProperty("tomcat.util.http.parser.HttpParser.requestTargetAllow","|{}");
但是也没解决问题
分析原因是因为url转化的问题 直接把名称转换之后再传给后端 测试了下 成功
在传入后端的中文中加入
encodeURI(fileName)解决!
去除前端所有的html标签方法
private static String delHTMLTag(String htmlStr){ String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式 String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式 Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); Matcher m_style=p_style.matcher(htmlStr); htmlStr=m_style.replaceAll(""); //过滤style标签 Pattern p_html= Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); Matcher m_html=p_html.matcher(htmlStr); htmlStr=m_html.replaceAll(""); //过滤html标签 htmlStr=htmlStr.replace(" ",""); htmlStr=htmlStr.replaceAll("\\s*|\t|\r|\n",""); htmlStr=htmlStr.replace("“",""); htmlStr=htmlStr.replace("”",""); htmlStr=htmlStr.replaceAll(" ",""); return htmlStr.trim(); //返回文本字符串 }