|
@@ -15,9 +15,11 @@ import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.mail.Session;
|
|
@@ -76,7 +78,15 @@ public class BannerTemplateController extends SimpleController {
|
|
|
private ISizeService sizeService;
|
|
|
@Autowired
|
|
|
Config config;
|
|
|
-
|
|
|
+
|
|
|
+ //文件系统可上传的文件后缀集合
|
|
|
+ private static Set<String> noStuffixSet = new HashSet<String>();
|
|
|
+
|
|
|
+ //初始化可上传文件后缀
|
|
|
+ static {
|
|
|
+ noStuffixSet.add("jpg");
|
|
|
+ noStuffixSet.add("gif");
|
|
|
+ }
|
|
|
|
|
|
@RequestMapping
|
|
|
public String index(Model model,
|
|
@@ -247,7 +257,12 @@ public class BannerTemplateController extends SimpleController {
|
|
|
|
|
|
//获取文件类型
|
|
|
fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
|
|
|
-
|
|
|
+
|
|
|
+ //判断文件类型
|
|
|
+ if(!noStuffixSet.contains(fileType)){
|
|
|
+ return "不支持此文件类型";
|
|
|
+ }
|
|
|
+
|
|
|
//如果名称不为“”,说明该文件存在,否则说明该文件不存在
|
|
|
if(uploadName.trim() !=""){
|
|
|
|
|
@@ -328,7 +343,12 @@ public class BannerTemplateController extends SimpleController {
|
|
|
|
|
|
//获取文件类型
|
|
|
fileType = uploadName.substring(uploadName.lastIndexOf(".") + 1);
|
|
|
-
|
|
|
+
|
|
|
+ //判断文件类型
|
|
|
+ if(!noStuffixSet.contains(fileType)){
|
|
|
+ return "不支持此文件类型";
|
|
|
+ }
|
|
|
+
|
|
|
//如果名称不为“”,说明该文件存在,否则说明该文件不存在
|
|
|
if(uploadName.trim() !=""){
|
|
|
|