- Java code
public class LoginAction extends ActionSupport { private String username; private String password; private UserService userService; private javax.servlet.http.HttpServletResponse response; // 获得HttpServletResponse对象 public void setServletResponse(HttpServletResponse response){ this.response = response; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String execute()throws JSONException, IOException,Exception { Users user=userService.find(username, password); if(user!=null){ Map session =(Map)ActionContext.getContext().getSession(); session.put("user",user); JSONObject json = new JSONObject();//这里错了,怎么解决? json.put("loginOK", true); json.put("success", true); response.getWriter().print(json); return null; }else return "fail"; }}
严重: Servlet.service() for servlet default threw exception
java.lang.NoClassDefFoundError: org/json/JSONException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at com.zeroturnaround.javarebel.lR.makeClassDeclaredMethodCache(JRebel:229)
at com.zeroturnaround.javarebel.lR.getClassDeclaredMethodCache(JRebel:158)
at com.zeroturnaround.javarebel.lR.getDeclaredMethods(JRebel:456)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at ognl.OgnlRuntime.getDeclaredMethods(OgnlRuntime.java:1719)
at ognl.OgnlRuntime.getSetMethod(OgnlRuntime.java:1814)
at ognl.OgnlRuntime.hasSetMethod(OgnlRuntime.java:1836)
at ognl.OgnlRuntime.hasSetProperty(OgnlRuntime.java:1854)
at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:64)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)