This commit is contained in:
2020-04-16 10:06:36 +08:00
parent a05953ec75
commit b796a1a839
6 changed files with 10383 additions and 51 deletions

View File

@@ -0,0 +1,35 @@
package com.yutou.tools.other;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@Controller
public class tools {
@ResponseBody
@RequestMapping(value = "tools/cookie.do",method = RequestMethod.POST)
public String cookieToJson(HttpServletRequest request){
JSONObject json=new JSONObject();
JSONArray array=new JSONArray();
for (Cookie cookie : request.getCookies()) {
JSONObject item=new JSONObject();
item.put("name",cookie.getName());
item.put("value",cookie.getValue());
item.put("domain",cookie.getDomain());
item.put("path",cookie.getPath());
item.put("maxAge",cookie.getMaxAge());
item.put("secure",cookie.getSecure());
item.put("isHttpOnly",cookie.isHttpOnly());
array.add(item);
}
json.put("data",array);
return json.toJSONString();
}
}