update
This commit is contained in:
35
src/main/java/com/yutou/tools/other/tools.java
Normal file
35
src/main/java/com/yutou/tools/other/tools.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user