• R/O
  • SSH
  • HTTPS

webserver: Commit


Commit MetaInfo

Revision50 (tree)
Time2010-10-05 02:05:50
Authorhoritaku

Log Message

修正

Change Summary

Incremental Difference

--- branch/Basic 0.2x/import_lib/lib/string/JSonUtil.java (nonexistent)
+++ branch/Basic 0.2x/import_lib/lib/string/JSonUtil.java (revision 50)
@@ -0,0 +1,35 @@
1+package lib.string;
2+
3+import java.util.ArrayList;
4+import java.util.HashMap;
5+import java.util.List;
6+
7+public class JSonUtil {
8+ public static String listToJSON(List<HashMap<String,String>> list) {
9+ ArrayList<String> recordList = new ArrayList<String>();
10+ for(HashMap<String,String> map:list) {
11+ ArrayList<String> setList = new ArrayList<String>();
12+ for(String key:map.keySet()) {
13+ String set = "'" + key + "':'" + map.get(key) + "'";
14+ setList.add(set);
15+ }
16+ String[] ary = new String[setList.size()];
17+ setList.toArray(ary);
18+ recordList.add("{" + join(",", ary) + "}");
19+ }
20+ String[] ary = new String[recordList.size()];
21+ recordList.toArray(ary);
22+ return "[" + join(",", ary) + "]";
23+ }
24+
25+ public static String join(String spacer, String[] ary) {
26+ if(ary.length == 0) {
27+ return "";
28+ }
29+ StringBuffer sb = new StringBuffer(ary[0]);
30+ for(int i = 1;i < ary.length;i++) {
31+ sb.append(spacer).append(ary[i]);
32+ }
33+ return sb.toString();
34+ }
35+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- branch/Basic 0.2x/reflectAction/refrect_action/LoginCheck.java (revision 49)
+++ branch/Basic 0.2x/reflectAction/refrect_action/LoginCheck.java (revision 50)
@@ -16,6 +16,7 @@
1616 res.setStatusCore(204);
1717 } else {
1818 res.setStatusCore(403);
19+ res.setResponseStr("Request was denied");
1920 }
2021 return res;
2122 }
--- branch/Basic 0.2x/reflectAction/refrect_action/ContentsList.java (revision 49)
+++ branch/Basic 0.2x/reflectAction/refrect_action/ContentsList.java (revision 50)
@@ -8,6 +8,7 @@
88 import servercore.http.HttpResponse;
99 import servercore.servelet.reflect.Action;
1010
11+import lib.string.JSonUtil;
1112 import models.ContentsBiz;
1213
1314 public class ContentsList extends Action{
@@ -20,10 +21,11 @@
2021 if("getall".equals(type)) {
2122 try {
2223 List<HashMap<String,String>> list = biz.getTitle();
24+ String data = JSonUtil.listToJSON(list);
25+ res.setResponseStr(data);
2326 } catch (Exception e) {
2427 throw e;
2528 }
26-
2729 }
2830 return res;
2931 }
--- branch/Basic 0.2x/src/servercore/http/HttpResponse.java (revision 49)
+++ branch/Basic 0.2x/src/servercore/http/HttpResponse.java (revision 50)
@@ -3,7 +3,7 @@
33 import java.util.HashMap;
44
55 public class HttpResponse {
6- private int statusCode;
6+ private int statusCode = 200;
77 private byte[] responseByte = new byte[0];
88 private long lastModified = 0;
99 private long contentLength = 0;
--- branch/Basic 0.2x/src/servercore/job/GeneratePage.java (revision 49)
+++ branch/Basic 0.2x/src/servercore/job/GeneratePage.java (revision 50)
@@ -42,6 +42,7 @@
4242 res.setStatusCore(404);
4343 } catch (Exception e) {
4444 res.setStatusCore(500);
45+ res.setResponseStr(e.getMessage());
4546 e.printStackTrace();
4647 }
4748 return res;
Show on old repository browser