网页出现乱码的解决办法
String content = teacher_mytask_detaillist.get(1)+"";//获取到数据库中的字段值,进行相应的替换
content = content.replaceAll("<", "<").replaceAll(">", ">");
content = content.replaceAll("(", "\(").replaceAll(")", "\)");
content = content.replaceAll("'", "'");
content = content.replaceAll(""", """);
把要显示的内容进行乱码替换
在对应项目的类文件下面添加白名单页面
添加方法
找到相应的过滤器xml文件,把需要过滤的文件添加进去。
下面内容是加了过滤器了 xss 跨站攻击的过滤器
[r00t@jspx006 classes]$ cat whatysecurity.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
<!-- 2??3??y?ò±í′?? -->
<exclusion>
<url value="/exclusion/test.jsp" />
<url value="/exclusion/test1.jsp" />
</exclusion>
<filters>
<!-- url?3??y?ò±í′?? -->
<filter name="xss">
<!-- 0 ±í?2??T?? 1±í?html?T???url?3??y?ò±í′?? 2?ì?дparm??2?2?êy£?2?êy?éò?,o???a-->
<item url="^/standard/blank_w+.action" param="a,b" type="0" />
<item url="^/examples/upload_upload.action" param="note" type="1" />
<item url="^/training/manager/courseware/enter_courseware.jsp" type="0" />
<item url="^/courseware/normalhttp/normalhttp_set.jsp" type="0" />
<item url="^/courseware/normalhttp/normalhttp_setexe.jsp" type="0" />
新增添加项<item url="^/training/classmanager/classnotice_add.jsp" type="0" />
修改编辑项<item url="^/training/classmanager/classnotice_edit.jsp" type="0" />
</filter>
<filter name="upload">
<!-- 1 ±í?′óС2??T?? 2±í?ààD???T?? 3??2??T?? url2??3??y?ò£?2?êy?éò?,o???a--><item url="/examples/upload_upload.action" param="file1" type="0" />
</filter>
<filter name="sql">
<!-- url?3??y?ò£?2?ì?дparm??2?2?êy£?2?êy?éò?,o???a-->
<item url="^/examples/upload_w+.action" param="field1,field2" />
</filter>
</filters>
</root>