简体   繁体   English

类型为Base64的方法encodeBase64(byte [])不适用于参数(String)

[英]The method decodeBase64(byte[]) in the type Base64 is not applicable for the arguments (String)

Upgraded from Java 1.6.2 to Java 1.7.25 and now on my JSP upon compiling I am getting the following: 从Java 1.6.2升级到Java 1.7.25,现在在我的JSP上进行编译时,我得到以下信息:

SEVERE: Servlet.service() for servlet [jsp] in context with path [/dswsbobje] threw exception [Unable to compile class for JSP: 严重:路径为[/ dswsbobje]的上下文中的servlet [jsp]的Servlet.service()引发了异常[无法为JSP编译类:

An error occurred at line: 40 in the jsp file: encrypt.jsp The method decodeBase64(byte[]) in the type Base64 is not applicable for the arguments (String) 在jsp文件:crypto.jsp中的第40行出现错误:Base64类型的方法encodeBase64(byte [])不适用于参数(字符串)

40:byte[] raw = Base64.decodeBase64(secret64); 40:字节[] raw = Base64.decodeBase64(secret64);

An error occurred at line: 47 in the jsp file: encrypt.jsp The method encodeBase64URLSafeString(byte[]) is undefined for the type Base64 在jsp文件:crypto.jsp中的第47行出现错误:对于类型Base64,未定义方法encodeBase64URLSafeString(byte [])。

47:out.write (" User Name " + userid + ": " + Base64.encodeBase64URLSafeString(cipher.doFinal(userid.getBytes()))); 47:out.write(“ 用户名” + userid +“: ” + Base64.encodeBase64URLSafeString(cipher.doFinal(userid.getBytes())));

What is causing these errors and how do I resolve them? 是什么导致这些错误,我该如何解决?

It seems that the class Base64 you're using was changed from one version to the other. 您正在使用的Base64类似乎已从一个版本更改为另一个版本。 You haven't provided the complete classname of this class but Google tells me that it should be Apache Commons Codec with version >= 1.4. 您尚未提供此类的完整类名,但是Google告诉我,它应该是版本> = 1.4的Apache Commons Codec。

It seems that you somehow are now using an older version of this library, because the methods the compiler complains about are added with version 1.4, so if you now use an older one, the methods can't be found. 看来您现在正在某种程度上使用该库的较旧版本,因为编译器抱怨的方法是在1.4版中添加的,因此,如果您现在使用较旧的方法,则找不到这些方法。

Replace the older library by a more recent one should fix your problem. 用较新的库替换较旧的库可以解决您的问题。 Alternatively you can change the calls of the methods to ones that already existed in older versions, eg 另外,您可以将方法的调用更改为旧版本中已经存在的方法,例如

byte[] raw = Base64.decodeBase64(secret64);

to

byte[] raw = Base64.decodeBase64(secret64.getBytes(charset));

and

Base64.encodeBase64URLSafeString(cipher.doFinal(userid.getBytes())));

to

new String(Base64.encodeBase64URLSafeString(cipher.doFinal(userid.getBytes(charset)))), "UTF-8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OutOfMemoryError 与 apache 公共 Base64 static 方法 decodeBase64 - OutOfMemoryError with apache commons Base64 static method decodeBase64 没有静态方法 decodeBase64 - Google 凭据 - No static method decodeBase64 - Google Credential Glassfish和Tomcat中的decodeBase64的不同结果 - Different results for decodeBase64 in Glassfish and Tomcat DecodeBase64使用apache commons - DecodeBase64 using apache commons Android v1p1beta1语音-java.lang.NoSuchMethodError:无静态方法encodeBase64 - Android v1p1beta1 Speech - java.lang.NoSuchMethodError: No static method decodeBase64 将Base64字符串转换为字节数组 - Conversion of Base64 String to byte array 使用Clojure的Apache Commons Codec解码Base64 - Using Apache Commons Codec decodeBase64 from Clojure 解码(通过python类型转换将类型转换为字符串的Base64编码数据)转换为JAVA中的字节数组 - Decoding (Base64 encoded data with type conversion to string by python type casting) to byte array in JAVA 如何将base64字符串图像解码为字节数组并将其作为blob类型存储在数据库中? - How to decode a base64 string image into byte array and store it as blob type in database? 将Base64编码的字节[]作为JSON MIME类型传递 - Pass Base64 encoded byte [] as a JSON MIME Type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM