package io.loli.sc.server.action;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;

@Named
@RequestMapping(value = { "/" })
public class HomeAction {

    @RequestMapping(value = { "/" })
    public String index() {
        return "index";
    }

    @RequestMapping(value = { "/download" })
    public String download(HttpServletRequest request) {
        String userAgent = request.getHeader("user-agent");
        List<String> list = new ArrayList<>();
        String current = getOs(userAgent);
        list.add("Windows");
        list.add("Mac");
        list.add("Linux");
        list.remove(current);
        request.setAttribute("list", list);
        request.setAttribute("current", current);
        return "download";
    }
    @RequestMapping(value = { "/file" })
    public String fileUpload(HttpServletRequest request) {
        String userAgent = request.getHeader("user-agent");
        List<String> list = new ArrayList<>();
        String current = getOs(userAgent);
        list.add("Windows");
        list.add("Mac");
        list.add("Linux");
        list.remove(current);
        request.setAttribute("list", list);
        request.setAttribute("current", current);
        return "image/fileUpload";
    }
    

    private String getOs(String userAgent) {
        if (userAgent.contains("Windows")) {
            return "Windows";
        } else if (userAgent.contains("Linux")) {
            return "Linux";
        } else if (userAgent.contains("Mac")) {
            return "Mac";
        } else {
            return "";
        }
    }
}

@@ -475,32 +475,50 @@
 uest request) %7B%0A
+        try %7B%0A    
         String u
@@ -561,32 +561,36 @@
 gent%22);%0A        
+    
 List%3CString%3E lis
@@ -612,32 +612,36 @@
 st%3C%3E();%0A        
+  
+  
 String current =
@@ -659,32 +659,36 @@
 Agent);%0A        
+    
 list.add(%22Window
@@ -692,32 +692,36 @@
 dows%22);%0A        
+  
+  
 list.add(%22Mac%22);
@@ -713,32 +713,36 @@
 ist.add(%22Mac%22);%0A
+    
         list.add
@@ -752,32 +752,36 @@
 inux%22);%0A        
+  
+  
 list.remove(curr
@@ -778,32 +778,36 @@
 emove(current);%0A
+    
         request.
@@ -834,32 +834,36 @@
  list);%0A        
+  
+  
 request.setAttri
@@ -880,32 +880,107 @@
 ent%22, current);%0A
+        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A
         return %22
@@ -992,24 +992,25 @@
 oad%22;%0A    %7D%0A
+%0A
     @Request
@@ -1487,26 +1487,21 @@
 pload%22;%0A
+
     %7D
-%0A    
 %0A%0A    pr

Add error handle on index