import com.google.gson.Gson;
// 序列和反序列化JSON
Gson gson = new Gson();
/** * 保存用户排序 * * * IOException */ @Action(value = "save_sort") public void save_sort() throws IOException { try { if (sortStr != null && !sortStr.equals("")) { List<UserSort> list = gson.fromJson(sortStr, new TypeToken<List<UserSort>>() { }.getType());
for (UserSort u : list) {
jdbc.update("update pub_user set sort=" + u.getSort() + ",status=" + u.getStatus() + " where user_id=" + u.getUser_id()); } } } catch (Exception e) { e.printStackTrace(); }res.setCharacterEncoding("utf-8");
PrintWriter print = res.getWriter(); print.print("true"); print.close(); }