@@ -28,8 +28,12 @@ public class ExamAdminService {
final String requestUrl = String.format("%s/api/ecs_exam_work/exam_student/query?student_id=%s", propertyService.getExamAdminUrl(), studentId);
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
if (result.isSuccess()) {
+ String data = result.getData();
+ //替换掉图片标签内容
+ data = HttpUtils.replaceImages(data);
//过滤掉为空的属性
- result.setData(HttpUtils.filterNullAttributes(result.getData()));
+ data = HttpUtils.filterNullAttributes(data);
+ result.setData(data);
}
return result;
@@ -103,10 +103,23 @@ public class HttpUtils {
+ /**
+ * 替换字符串中所有的图片标签
+ */
+ public static String replaceImages(String html) {
+ if (html == null) {
+ return null;
+ }
+ String reg = "<\\s*img\\s+([^>]*)\\s*>";
+ return html.replaceAll(reg, "");
+
/*public static void main(String[] args) {
String json = "{\"id\":1,\"answer\":null,\"question\":{\"id\":2,\"answer\":null,\"question\":{\"id\":3,\"answer\":null,\"question\":{\"id\":4,\"answer\":null,,\"question\":{\"id\":5,\"answer\":null}}}}}";
String result = HttpUtils.filterNullAttributes(json);
System.out.println(result);
+ String html = "111< img src='' >222< img / >333";
+ System.out.println(replaceImages(html));
}*/