{"action":"closed","issue":{"url":"https://api.github.com/repos/nutzam/nutz/issues/639","labels_url":"https://api.github.com/repos/nutzam/nutz/issues/639/labels{/name}","comments_url":"https://api.github.com/repos/nutzam/nutz/issues/639/comments","events_url":"https://api.github.com/repos/nutzam/nutz/issues/639/events","html_url":"https://github.com/nutzam/nutz/issues/639","id":32812639,"number":639,"title":"Cookie设置和获取问题","user":{"login":"Gaion","id":7481093,"avatar_url":"https://avatars.githubusercontent.com/u/7481093?v=3","gravatar_id":"","url":"https://api.github.com/users/Gaion","html_url":"https://github.com/Gaion","followers_url":"https://api.github.com/users/Gaion/followers","following_url":"https://api.github.com/users/Gaion/following{/other_user}","gists_url":"https://api.github.com/users/Gaion/gists{/gist_id}","starred_url":"https://api.github.com/users/Gaion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gaion/subscriptions","organizations_url":"https://api.github.com/users/Gaion/orgs","repos_url":"https://api.github.com/users/Gaion/repos","events_url":"https://api.github.com/users/Gaion/events{/privacy}","received_events_url":"https://api.github.com/users/Gaion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-05-05T14:18:30Z","updated_at":"2015-02-11T10:17:47Z","closed_at":"2015-02-11T10:17:47Z","body":"@At(\"/sys\")\r\n@IocBean\r\npublic class SystemModule{\r\n\t@At\r\n\t@Ok(\"jsp:index\")\r\n\tpublic void index(HttpSession session,HttpServletRequest request) {\r\n\t\tCookie[] cs = request.getCookies();\r\n\t\tif(null != cs) {\r\n\t\t\tfor(Cookie c : cs) System.out.println(c.getName() + \"-----\" + c.getValue());\r\n\t\t}\r\n\t\tMvcs.getResp().addCookie(new Cookie(\"bbbb\",\"2222\"));\r\n\t}\r\n\t@At\r\n\t@Ok(\"jsp:index\")\r\n\tpublic View login(HttpSession session,HttpServletRequest request) {\r\n\t\tMvcs.getResp().addCookie(new Cookie(\"aaaa\",\"1111\"));\r\n\t}\r\n}\r\n\r\n@At(\"/report\")\r\n@IocBean\r\npublic class ReportModule{\r\n\t@At\r\n\t@Ok(\"jsp:index\")\r\n\tpublic void manager(HttpSession session,HttpServletRequest request) {\r\n\t\tCookie[] cs = request.getCookies();\r\n\t\tif(null != cs) {\r\n\t\t\tfor(Cookie c : cs) System.out.println(c.getName() + \"-----\" + c.getValue());\r\n\t\t}\r\n\t\tMvcs.getResp().addCookie(new Cookie(\"cccc\",\"3333\"));\r\n\t}\r\n\t@At\r\n\t@Ok(\"jsp:index\")\r\n\tpublic void add(HttpSession session,HttpServletRequest request) {\r\n\t\tCookie[] cs = request.getCookies();\r\n\t\tif(null != cs) {\r\n\t\t\tfor(Cookie c : cs) System.out.println(c.getName() + \"-----\" + c.getValue());\r\n\t\t}\r\n\t\tMvcs.getResp().addCookie(new Cookie(\"dddd\",\"4444\"));\r\n\t}\r\n}\r\n\r\ntest2.jsp\r\n<%\r\nresponse.addCookie(new Cookie(\"eeee\",\"5555\"));\r\n%>\r\n\r\n发现在两个类中都只能获取到自身设置的cookie，只有在jsp文件中设置的cookie才能不受限制\r\n\r\n测试顺序如下：\r\n\t1.打开：/sys/login        后台无输出\r\n\t2.打开：/sys/index        后台输出：  aaaa-----1111\r\n\t3.打开：/sys/index        后台输出：  aaaa-----1111   bbbb-----2222\r\n\t4.打开：/report/manager   后台无输出\r\n\t5.打开：/report/add       后台输出：  cccc-----3333\r\n\t6.打开：text2.jsp\r\n\t7.打开：/sys/index        后台输出：  aaaa-----1111  bbbb-----2222  eeee-----5555\r\n\r\n应该怎么做才能在这些类之间共享cookie？刚开始接触nutz，相当不熟悉，只好来这里求助了……"}}