SoFunction
Updated on 2025-04-05

Solution to the problem of using jstl to import html garbled code in jsp

When importing html through jst's <c:import> in jsp, the reason is that

If the value of charEncoding is empty, charEncoding will appear as the default value, which is ISO-8859-1

Fortunately, charEncoding can be set directly through <c:import>, so it is enough to set it up. Many people say that contentType can be set by meta in html, but I have tried it but it doesn't work. It was only by looking at the source code of jstl that I found that I can set this, because I usually use cimport to import jsp, and setting in jsp is feasible, but not in static pages. Here is the main code for ImportSupport:

Copy the codeThe code is as follows:

 Reader r = null;
      String charSet;
      String charSet;
      if (( != null) && (!(""))) {
        charSet = ;
      }
      else {
        String contentType = ();
        if (contentType != null) {
          String charSet = (contentType, "charset");
          if (charSet == null) charSet = "ISO-8859-1";
        }
        else {
          charSet = "ISO-8859-1";
        }
      }