当我将值传递给其他函数时,我在下面的代码中收到错误,所有错误都与异常生成有关,但是我无法进行排序,因为我正在日食工作,它建议在findMeaning传递函数中使用trycatch块,但是这对我不起作用,我收到建议后得到的输出为空,请参见下面的代码

public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException
    {


        String searchWord= req.getParameter("txtweb-message");
        if (searchWord == null|| searchWord.isEmpty())
            sendResponse(resp,"for decrypt msg write @secretmsg.de (msg)");
        else

                findMeaning(resp,searchWord);//getting exception error here


           }

将价值传递给功能,

private void findMeaning(HttpServletResponse resp,String plainText) throws MalformedURLException, NoSuchAlgorithmException, 
    InvalidKeySpecException, 
    NoSuchPaddingException, 
    InvalidKeyException,
    InvalidAlgorithmParameterException, 
    UnsupportedEncodingException, 
    IllegalBlockSizeException, 
    BadPaddingException{ 





        /**
         * 
         * @param secretKey Key used to encrypt data
         * @param plainText Text input to be encrypted
         * @return Returns encrypted text
         * 
         */
        String secretKey = "ezeon8547";


            //Key generation for enc and desc
            KeySpec keySpec = new PBEKeySpec(secretKey.toCharArray(), salt, iterationCount);
            SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);        
             // Prepare the parameter to the ciphers
            AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);

            //Enc process
            ecipher = Cipher.getInstance(key.getAlgorithm());
            ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);      
            String charSet="UTF-8";       
            byte[] in = plainText.getBytes(charSet);
            byte[] out = ecipher.doFinal(in);
            String encStr=new sun.misc.BASE64Encoder().encode(out);

              sendResponse(resp, "Pincode city:" +encStr);

         /**     
         * @param secretKey Key used to decrypt data
         * @param encryptedText encrypted text input to decrypt
         * @return Returns plain text after decryption
         */



    }

===============>>#1 票数:0

您的调用函数抛出

throws MalformedURLException, NoSuchAlgorithmException,

因此,当您调用此函数时,您的调用代码应声明或捕获此类异常。 它被说成是异常传播。

  ask by satish translate from so

未解决问题?本站智能推荐: