【问题标题】:how to use Base64.getEncoder().encodeToString() and Base64.encodeBase64String() together in single file如何在单个文件中同时使用 Base64.getEncoder().encodeToString() 和 Base64.encodeBase64String()
【发布时间】:2017-02-06 11:09:31
【问题描述】:

我有一个jsp文件,我需要在其中使用Base64类的方法。 java.util 中存在一种方法:

java.util.Base64.getEncoder().encodeToString().

另外一个方法存在于

    org.apache.commons.codec.binary package :
    org.apache.commons.codec.binary.Base64.encodeBase64String()

为了实现这一点,我使用了完全分类的名称,但仍然报错。

org.apache.jasper.JasperException:无法为 JSP 编译类:一个 错误发生在 jsp 文件中的第 59 行:/ProcessDetails.jsp org.apache.commons.codec.binary.Base64 无法解析为类型 56:字符串签名= java.util.Base64.getEncoder().encodeToString(sha256_HMAC.doF‌​inal(data.getBytes()‌​)); 59:字符串支付令牌= org.apache.commons.codec.binary.Base64.encodeBase64String(sh‌​a256_HMAC.doFinal(da‌​ta.getBytes()));

【问题讨论】:

  • "但仍然报错" - 什么错误?
  • 欢迎堆栈溢出 :-) 请不要将相关信息(错误消息和代码)添加到 cmets,而是添加到问题中

标签: java


【解决方案1】:

听起来您可能缺少 WEB-INF/lib 中的 apache commons jar 见jsp "unable to compile" and "cannot be resolved to a type"

或者您的 JSP 中可能缺少导入语句 见Unable to compile class for JSP: cannot be resolved to a type

希望有帮助

【讨论】:

    猜你喜欢
    • 2014-01-09
    • 2019-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 1970-01-01
    相关资源
    最近更新 更多