代码之家  ›  专栏  ›  技术社区  ›  beck

cn1-尝试调用虚拟方法“boolean”java.util.ArrayList.添加(java.lang.Object对象)'在空对象引用上

  •  1
  • beck  · 技术社区  · 6 年前

    if (!regNOField.getText().equals("") && !newPasswordField.getText().equals("")) {
        ArrayList<Map<String, String>> argumentsArrayList = new ArrayList<>();
    
        Map argumentMap1 = new HashMap();
        argumentMap1.put("argument", "reg_no");
        argumentMap1.put("value", regNOField.getText().trim());
        argumentsArrayList.add(argumentMap1);
    
        Map argumentMap2 = new HashMap();
        argumentMap2.put("argument", "token");
        argumentMap2.put("value", newPasswordField.getText().trim());
        argumentsArrayList.add(argumentMap2);
    
        CommonMethod.connectionMethod(res, true, url, "Verification", argumentsArrayList, true, null);
    }
    

    CommonMethod.connectionMethod方法:

    public static void connectionMethod(Resources res, Boolean postBoolean, String urlString, String form, ArrayList<Map<String, String>> arguments,
            Boolean ipFlag, String extraData) {
        ConnectionRequest cr = new ConnectionRequest() {
    
            @Override
            protected void readResponse(InputStream input) throws IOException {
                JSONParser jp = new JSONParser();
                parser = jp.parseJSON(new InputStreamReader(input));
                response = null;
                if (parser != null && !parser.isEmpty()) {
                    if (parser.get("status").equals("true")) {
                        message = (String) parser.get("data");
                        ToastBar.getInstance().setPosition(Component.TOP);
                        ToastBar.showErrorMessage(message, 5000);
                        if (form.equals("Verification")) {
                            if (d != null) {
                                d.dispose();
                            }
                            new LoginAndSignUp(res, message).show();
                        }  
                    } 
                }
            }
    
            @Override
            protected void handleErrorResponseCode(int code, String message) {
                System.out.println("login ErrorResponseCode " + code + "msg: " + message);
            }
    
            @Override
            protected void handleException(Exception err) {
                System.out.println("login Exception " + err);
            }
    
            @Override
            protected void handleIOException(IOException err) {
                System.out.println("login IOException " + err);
            }
    
            @Override
            protected void handleRuntimeException(RuntimeException err) {
                System.out.println("RuntimeException " + err);
            }
        };
        cr.setPost(postBoolean);
        cr.setUrl(urlString);
        cr.setTimeout(80000);
        if (arguments != null && !postBoolean.equals(false)) {
            for (Map<String, String> entrySet : arguments) {
                String argument1 = (String) entrySet.get("argument");
                String value1 = (String) entrySet.get("value");
                cr.addArgument(argument1, value1);
            }
        }
        InfiniteProgress ip = new InfiniteProgress();
        d = ip.showInifiniteBlocking();
        cr.setDisposeOnCompletion(d);
        cr.addRequestHeader("accept", "application/json");
        NetworkManager.getInstance().addToQueueAndWait(cr);
    }
    

    错误消息:

    enter image description here

    0 回复  |  直到 6 年前