Base64Encoder cannot be resolved

前端 未结 4 1044
一个人的身影
一个人的身影 2020-12-31 13:10

This is my Java code in a JSP file. I am getting

Base64Encoder cannot be resolved.

Why is it so? I have to add something relat

4条回答
  •  星月不相逢
    2020-12-31 13:41

    Looks like you are using a class that does not exist in a jar you have included in the web application. Can you try the following? Make adjustments if necessary, I am just looking at the documentation for commons and typing this out --

    1. Go to http://commons.apache.org/codec/index.html and read through the information there
    2. Now go to http://commons.apache.org/codec/download_codec.cgi and download the zip file
    3. Extract out the jar file and copy it to the lib directory of your web application
    4. Replace the line [String encoding = Base64Encoder.encode ("test:test");]

    with

    String encoding = new String(
     org.apache.commons.codec.binary.Base64.encodeBase64   
        (org.apache.commons.codec.binary.StringUtils.getBytesUtf8("test:test"))
      );
    

提交回复
热议问题