SoFunction
Updated on 2025-03-08

A brief discussion on the garbled problem of jsp files and HTML introducing each other

1. Problems encountered when using include directive to import HTML files in jsp:

Both jsp and html can be displayed correctly. When jsp introduces html, the HTML of the jsp page will appear garbled. The original output of jsp is not garbled. Solution:

Add in the first line of HTML: <%@ page language="java" import=".*" pageEncoding="utf-8"%>

The encoding format of jsp is: <%@ page language="java" import=".*" contentType="text/html;charset=UTF-8" pageEncoding="utf-8"%>

2. The problem of garbled code when converting the html page to a jsp page:

Assuming the original html is encoded as utf-8, add <%@ page pageEncoding="utf-8"%> to the top of the html

Then modify the suffix to .jsp, that is, first modify the encoding format and convert it to jsp file

The above article briefly discusses the garbled code problem introduced by jsp files and HTML is all the content I share with you. I hope you can give you a reference and I hope you can support me more.