在我的Action的execute()函数中, public String execute(){ System.out.println("action"); if(getUser().equals("liu")&&getPassword().equals("shilei")){ ActionContext.getContext().getSession().put("user", getUser()); Cookie cookie=new Cookie("user",user); cookie.setMaxAge(60*60); response.addCookie(cookie);//就是这里出错了 return SUCCESS; } return ERROR; } 执行后的结果 java.lang.NullPointerException action.LoginAction.execute(LoginAction.java:38) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) response我是在Action中声明的一个private HttpServletResponse response;
收到一只叮咚